Merge pull request #3982 from panda01/fix/2986/useNativeWidthToStopReflow

Use native width and height to stop Reflows
This commit is contained in:
Joe Fleming 2015-05-27 15:15:15 -07:00
commit 881ab58718
2 changed files with 9 additions and 14 deletions

View file

@ -52,8 +52,8 @@ define(function (require) {
*/
ResizeChecker.prototype.read = function () {
return {
w: this.$el.width(),
h: this.$el.height()
w: this.$el[0].clientWidth,
h: this.$el[0].clientHeight
};
};
@ -204,4 +204,4 @@ define(function (require) {
return ResizeChecker;
};
});
});

View file

@ -59,17 +59,12 @@ define(function (require) {
});
describe('#read', function () {
it('uses jquery to get the width and height of the element', function () {
var stubw = sinon.spy($.fn, 'width');
var stubh = sinon.spy($.fn, 'height');
it('gets the proper dimensions for the element', function () {
var dimensions = checker.read();
var windowWidth = window.innerWidth;
checker.read();
expect(stubw).to.have.property('callCount', 1);
expect(stubw.getCall(0)).to.have.property('thisValue', checker.$el);
expect(stubh).to.have.property('callCount', 1);
expect(stubh.getCall(0)).to.have.property('thisValue', checker.$el);
expect(dimensions.w).to.equal(windowWidth);
expect(dimensions.h).to.equal(0);
});
});
@ -203,4 +198,4 @@ define(function (require) {
});
});
});
});
});