Skip to content
Browse files

More basic methods, tests

  • Loading branch information...
1 parent e3c8a6a commit 274d2bcb562312e355983030c138f996c0e674fd @fakedarren committed
Showing with 108 additions and 2 deletions.
  1. +53 −1 lib/dimensions.js
  2. +16 −0 nodes.js
  3. +39 −1 test/test.dimensions.sizes.js
View
54 lib/dimensions.js
@@ -1,9 +1,12 @@
/*
-nodes insertion
+nodes dimensions
*/"use strict"
var $ = require("./list")
+/*
+size
+*/
$.implement({
getSize: function(){
@@ -16,4 +19,53 @@ $.implement({
})
+/*
+scroll
+*/
+$.implement({
+
+ getScrollSize: function(){
+ var el = this[0]
+ return {
+ x: el.scrollWidth,
+ y: el.scrollHeight
+ }
+ },
+
+ getScroll: function(){
+ var el = this[0]
+ return {
+ x: el.scrollLeft,
+ y: el.scrollTop
+ }
+ }
+
+})
+
+/*
+offset
+*/
+$.implement({
+
+ getOffsetParent: function(){
+ },
+
+ getOffsets: function(){
+ }
+
+})
+
+/*
+position
+*/
+$.implement({
+
+ getPosition: function(){
+ },
+
+ getCoordinates: function(){
+ }
+
+})
+
module.exports = $
View
16 nodes.js
@@ -1202,6 +1202,22 @@
};
}
});
+ $.implement({
+ getScrollSize: function() {
+ var el = this[0];
+ return {
+ x: el.scrollWidth,
+ y: el.scrollHeight
+ };
+ },
+ getScroll: function() {
+ var el = this[0];
+ return {
+ x: el.scrollLeft,
+ y: el.scrollTop
+ };
+ }
+ });
module.exports = $;
}
});
View
40 test/test.dimensions.sizes.js
@@ -1,4 +1,4 @@
-describe('getSize()', function (){
+describe('getSize()', function(){
var test
@@ -14,3 +14,41 @@ describe('getSize()', function (){
})
})
+
+describe('getScrollSize', function(){
+
+ var test
+
+ before(function(){
+ test = nodes('#scrolltest')
+ test[0].scrollTop = 20
+ test[0].scrollLeft = 20
+ })
+
+ it('should calculate scroll size', function(){
+ var scrollSize = test.getScrollSize()
+ expect(scrollSize).to.have.keys('x', 'y')
+ expect(scrollSize.x).to.be(120)
+ expect(scrollSize.y).to.be(120)
+ })
+
+})
+
+describe('getScrollSize', function(){
+
+ var test
+
+ before(function(){
+ test = nodes('#scrolltest')
+ test[0].scrollTop = 20
+ test[0].scrollLeft = 20
+ })
+
+ it('should calculate scroll', function(){
+ var scroll = test.getScroll()
+ expect(scroll).to.have.keys('x', 'y')
+ expect(scroll.x).to.be(20)
+ expect(scroll.y).to.be(20)
+ })
+
+})

0 comments on commit 274d2bc

Please sign in to comment.
Something went wrong with that request. Please try again.