cartodb-4.42/lib/assets/javascripts/cartodb/common/views/scrollable_header.js
2024-04-06 05:25:13 +00:00

28 lines
584 B
JavaScript

var cdb = require('cartodb.js-v3');
module.exports = cdb.core.View.extend({
initialize: function() {
_.bindAll(this, '_onWindowScroll');
this._bindScroll();
},
_onWindowScroll: function() {
this.$el.toggleClass('is-fixed', $(window).scrollTop() > this.options.anchorPoint);
},
_unbindScroll: function() {
$(window).unbind('scroll', this._onWindowScroll);
},
_bindScroll: function() {
this._unbindScroll();
$(window).bind('scroll', this._onWindowScroll);
},
clean: function() {
this._unbindScroll();
this.elder('clean');
}
});