-
Notifications
You must be signed in to change notification settings - Fork 5
/
deck.pointer.js
51 lines (41 loc) · 1.54 KB
/
deck.pointer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
(function($, deck, undefined) {
var $d = $(document);
$.extend(true, $[deck].defaults, {
classes: {
pointer: 'deck-pointer'
},
keys: {
pointer: 80 // p
}
});
$[deck]('extend', 'showPointer', function() {
$[deck]('getContainer').addClass($[deck]('getOptions').classes.pointer);
$[deck]('getContainer').unbind('mousemove.deckpointer').bind('mousemove.deckpointer', function(e){
pointer = $('<div>').attr({'class':'pointer'});
$[deck]('getContainer').append(pointer);
pointer.css({
top: e.pageY,
left: e.pageX
}).fadeOut(1500, function(){
$(this).remove();
});
});
});
$[deck]('extend', 'hidePointer', function() {
$[deck]('getContainer').removeClass($[deck]('getOptions').classes.pointer);
$[deck]('getContainer').unbind('mousemove.deckpointer');
});
$[deck]('extend', 'togglePointer', function() {
$[deck]('getContainer').hasClass($[deck]('getOptions').classes.pointer) ?
$[deck]('hidePointer') : $[deck]('showPointer');
});
$d.bind('deck.init', function() {
var opts = $[deck]('getOptions');
$d.unbind('keydown.deckpointer').bind('keydown.pointer', function(e) {
if (e.which === opts.keys.pointer || $.inArray(e.which, opts.keys.pointer) > -1) {
$[deck]('togglePointer');
e.preventDefault();
}
});
});
})(jQuery, 'deck');