Open juandavm opened 3 years ago
Happy to add these, if somebody can manage to squeeze enough bytes out of the bundle, I think we are currently nearly at 6kb min+giz, I don't want to exceed that.
@juandavm, meanwhile, I recommend creating cash-extends.js file with all new methods you need. Here is a scrollTop implementation:
$.fn.scrollTop = function (val) {
var el = this.get(0);
if (val === undefined) {
return el ? el.scrollTop : null;
}
if (el) {
el.scrollTop = val;
}
return this;
};
@vovayatsyuk Actually that might be buggy because this.get (0)
can return undefined
.
Ah, yes.. Fixed now. I hope :)
Thank you.
p.s. Fixed one more time.🤫
Cash has removed the shortcuts like ".scroll" ".click" (basically it is $(...).on("scroll", ...)
)
Similarly, you shall use $(...).prop("scrollTop", ... )
instead.
$.fn.scrollTop = function (val) {
if (val === undefined) {
return this.prop('scrollTop');
}
return this.prop('scrollTop', val);
};
@juandavm, meanwhile, I recommend creating cash-extends.js file with all new methods you need. Here is a scrollTop implementation:
$.fn.scrollTop = function (val) { var el = this.get(0); if (val === undefined) { return el ? el.scrollTop : null; } if (el) { el.scrollTop = val; } return this; };
Replaced el.scrollTop
with el.pageYOffset
and everything works fine:
$.fn.scrollTop = function (val) {
var el = this.get(0);
if (val === undefined) {
return el ? el.pageYOffset : null;
}
if (el) {
el.pageYOffset = val;
}
return this;
}
@juandavm, meanwhile, I recommend creating cash-extends.js file with all new methods you need. Here is a scrollTop implementation:
$.fn.scrollTop = function (val) { var el = this.get(0); if (val === undefined) { return el ? el.scrollTop : null; } if (el) { el.scrollTop = val; } return this; };
Replaced
el.scrollTop
withel.pageYOffset
and everything works fine:$.fn.scrollTop = function (val) { var el = this.get(0); if (val === undefined) { return el ? el.pageYOffset : null; } if (el) { el.pageYOffset = val; } return this; }
But it's not working!
Happy to add these, if somebody can manage to squeeze enough bytes out of the bundle, I think we are currently nearly at 6kb min+giz, I don't want to exceed that.
Can we have partial build option so that there will be "polyfill" for .click
, .scroll
, etc which are excluded by default, but user can do the partial build to add @require events/click.ts
(the ts file is provided in this repo)
This can help users to do migration easier and they might not care about the file size increment.
Please, support the jQuery scrollTop method https://api.jquery.com/scrolltop/
It's a widely used method of jQuery