Skip to content

Commit a9c037f

Browse files
author
Lawrence Goldstien
committed
Fix #10 - Added functionality for parent option and wrote tests
1 parent 51822e0 commit a9c037f

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

dragpan.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "dragpan",
33
"title": "Dragpan",
44
"description": "A jQuery plugin designed to allow click and drag panning of a scrollable element",
5-
"version": "1.0.0",
5+
"version": "1.0.1",
66
"homepage": "https://github.com/lgoldstien/jquery-dragpan",
77
"author": {
88
"name": "Lawrence Goldstien",

src/dragpan.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ $.widget( "oml.dragpan", {
5858
} else {
5959
_this.options = $.extend( _this._defaults, _this.options );
6060
}
61+
if (typeof _this.options.parent === 'object') {
62+
_this.options.$parent = _this.options.parent;
63+
}
6164

6265
// Set up the variables used in the function
6366

test/dragpan_test.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,17 @@
4949
strictEqual($('#parent').css('cursor'), 'all-scroll', 'the parent should have an all-scroll cursor by default');
5050
});
5151

52-
module('Dragpan With Options', {
53-
setup: function () {
54-
this.elems = $('#parent').dragpan({ cursor: 'pointer', speedX: 50, speedY: 60 });
55-
}
56-
});
52+
module('Dragpan With Options', {});
5753

5854
test('Drapan uses specified cursor', function() {
5955
expect(1);
56+
$('#parent').dragpan({ cursor: 'pointer' });
57+
strictEqual($('#parent').css('cursor'), 'pointer', 'the parent should have a pointer cursor for this test');
58+
});
59+
60+
test('Drapan uses specified parent', function() {
61+
expect(1);
62+
$('#child').dragpan({ parent: $('#parent') });
6063
strictEqual($('#parent').css('cursor'), 'pointer', 'the parent should have a pointer cursor for this test');
6164
});
6265

@@ -69,7 +72,11 @@
6972

7073
test('defaul cursor', function() {
7174
expect(1);
72-
strictEqual($('#parent').css('cursor'), 'default', 'the parent should have a pointer cursor for this test');
75+
var cursor = false;
76+
if ( $('#parent').css('cursor') === 'default' || $('#parent').css('cursor') === 'auto' ) {
77+
cursor = true;
78+
}
79+
strictEqual( cursor, true, 'the parent should have a default cursor for this test');
7380
});
7481

7582

0 commit comments

Comments
 (0)