Merge lp:~sil/novacut-prototypes/mousewheel-slices into lp:novacut-prototypes

Proposed by Stuart Langridge on 2011-07-14
Status: Merged
Merged at revision: 19
Proposed branch: lp:~sil/novacut-prototypes/mousewheel-slices
Merge into: lp:novacut-prototypes
Diff against target: 107 lines (+89/-1)
1 file modified
sequence-jderose-1.html (+89/-1)
To merge this branch: bzr merge lp:~sil/novacut-prototypes/mousewheel-slices
Reviewer Review Type Date Requested Status
Novacut Prototypes Dev 2011-07-14 Pending
Review via email: mp+68003@code.launchpad.net

Description of the change

Allow mousewheel adjustment of the start and end frame of a slice. Hard work done by https://github.com/brandonaaron/jquery-mousewheel/ which is MIT licensed; don't know if that's OK to use.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sequence-jderose-1.html'
2--- sequence-jderose-1.html 2011-07-14 10:28:18 +0000
3+++ sequence-jderose-1.html 2011-07-14 18:13:07 +0000
4@@ -17,7 +17,84 @@
5 }
6
7
8-
9+/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
10+ * Licensed under the MIT License (LICENSE.txt).
11+ *
12+ * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
13+ * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
14+ * Thanks to: Seamus Leahy for adding deltaX and deltaY
15+ *
16+ * Version: 3.0.4
17+ *
18+ * Requires: 1.2.2+
19+ */
20+
21+(function($) {
22+
23+var types = ['DOMMouseScroll', 'mousewheel'];
24+
25+$.event.special.mousewheel = {
26+ setup: function() {
27+ if ( this.addEventListener ) {
28+ for ( var i=types.length; i; ) {
29+ this.addEventListener( types[--i], handler, false );
30+ }
31+ } else {
32+ this.onmousewheel = handler;
33+ }
34+ },
35+
36+ teardown: function() {
37+ if ( this.removeEventListener ) {
38+ for ( var i=types.length; i; ) {
39+ this.removeEventListener( types[--i], handler, false );
40+ }
41+ } else {
42+ this.onmousewheel = null;
43+ }
44+ }
45+};
46+
47+$.fn.extend({
48+ mousewheel: function(fn) {
49+ return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
50+ },
51+
52+ unmousewheel: function(fn) {
53+ return this.unbind("mousewheel", fn);
54+ }
55+});
56+
57+
58+function handler(event) {
59+ var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
60+ event = $.event.fix(orgEvent);
61+ event.type = "mousewheel";
62+
63+ // Old school scrollwheel delta
64+ if ( event.wheelDelta ) { delta = event.wheelDelta/120; }
65+ if ( event.detail ) { delta = -event.detail/3; }
66+
67+ // New school multidimensional scroll (touchpads) deltas
68+ deltaY = delta;
69+
70+ // Gecko
71+ if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
72+ deltaY = 0;
73+ deltaX = -1*delta;
74+ }
75+
76+ // Webkit
77+ if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
78+ if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }
79+
80+ // Add event and delta to the front of the arguments
81+ args.unshift(event, delta, deltaX, deltaY);
82+
83+ return $.event.handle.apply(this, args);
84+}
85+
86+})(jQuery);
87
88 $(document).ready(function(){
89 data.forEach(function(doc){
90@@ -41,6 +118,17 @@
91 div.addClass('selected');
92 selected = doc._id;
93 });
94+ div.children("img").mousewheel(function(e, d, dx, dy) {
95+ /* if over the top image, adjust start. Otherwise adjust end */
96+ if (e.target == $('#' + doc._id + ' :first-child')[0]) {
97+ docs[doc._id].start += dy;
98+ } else {
99+ docs[doc._id].stop += dy;
100+ }
101+ e.preventDefault();
102+ $('#' + doc._id + ' :first-child').attr('src', thumbnail(doc._id, doc.start));
103+ $('#' + doc._id + ' :last-child').attr('src', thumbnail(doc._id, doc.stop));
104+ });
105
106 });
107 $('#sequence1').sortable({'axis': 'x', 'opacity': 0.6});

Subscribers

People subscribed via source and target branches