mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Merge pull request #6216 from kevinansfield/remove-set-scroll-classname
Remove `setScrollClassName` mixin and usage
This commit is contained in:
commit
450b7085d7
5 changed files with 2 additions and 72 deletions
|
@ -1,24 +1,12 @@
|
|||
import Ember from 'ember';
|
||||
import setScrollClassName from 'ghost/utils/set-scroll-classname';
|
||||
|
||||
const {Component, run} = Ember;
|
||||
const {Component} = Ember;
|
||||
|
||||
export default Component.extend({
|
||||
classNames: ['content-preview-content'],
|
||||
|
||||
content: null,
|
||||
|
||||
didInsertElement() {
|
||||
this._super(...arguments);
|
||||
|
||||
let el = this.$();
|
||||
|
||||
el.on('scroll', run.bind(el, setScrollClassName, {
|
||||
target: el.closest('.content-preview'),
|
||||
offset: 10
|
||||
}));
|
||||
},
|
||||
|
||||
didReceiveAttrs(options) {
|
||||
this._super(...arguments);
|
||||
|
||||
|
@ -30,13 +18,5 @@ export default Component.extend({
|
|||
el.closest('.content-preview').scrollTop(0);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
this._super(...arguments);
|
||||
|
||||
let el = this.$();
|
||||
|
||||
el.off('scroll');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import Ember from 'ember';
|
||||
import setScrollClassName from 'ghost/utils/set-scroll-classname';
|
||||
|
||||
const {Component, computed, run} = Ember;
|
||||
const {equal} = computed;
|
||||
|
@ -54,17 +53,6 @@ export default Component.extend({
|
|||
// cache these elements for use in other methods
|
||||
this.set('$previewViewPort', $previewViewPort);
|
||||
this.set('$previewContent', this.$('.js-rendered-markdown'));
|
||||
|
||||
$previewViewPort.on('scroll', run.bind($previewViewPort, setScrollClassName, {
|
||||
target: this.$('.js-entry-preview'),
|
||||
offset: 10
|
||||
}));
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
this._super(...arguments);
|
||||
// removes scroll handlers from the view
|
||||
this.get('$previewViewPort').off('scroll');
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
|
|
@ -1,23 +1,7 @@
|
|||
import Ember from 'ember';
|
||||
import InfiniteScrollMixin from 'ghost/mixins/infinite-scroll';
|
||||
import setScrollClassName from 'ghost/utils/set-scroll-classname';
|
||||
|
||||
const {Component, run} = Ember;
|
||||
const {Component} = Ember;
|
||||
|
||||
export default Component.extend(InfiniteScrollMixin, {
|
||||
didInsertElement() {
|
||||
let el = this.$();
|
||||
|
||||
this._super(...arguments);
|
||||
|
||||
el.on('scroll', run.bind(el, setScrollClassName, {
|
||||
target: el.closest('.content-list'),
|
||||
offset: 10
|
||||
}));
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
this._super(...arguments);
|
||||
this.$().off('scroll');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import Ember from 'ember';
|
||||
import setScrollClassName from 'ghost/utils/set-scroll-classname';
|
||||
|
||||
const {Mixin, run} = Ember;
|
||||
|
||||
|
@ -75,10 +74,6 @@ export default Mixin.create({
|
|||
$el.on('keypress', run.bind(this, this.adjustScrollPosition));
|
||||
|
||||
$el.on('scroll', run.bind(this, this.scrollHandler));
|
||||
$el.on('scroll', run.bind($el, setScrollClassName, {
|
||||
target: Ember.$('.js-entry-markdown'),
|
||||
offset: 10
|
||||
}));
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
// ## scrollShadow
|
||||
// This adds a 'scroll' class to the targeted element when the element is scrolled
|
||||
// `this` is expected to be a jQuery-wrapped element
|
||||
// **target:** The element in which the class is applied. Defaults to scrolled element.
|
||||
// **class-name:** The class which is applied.
|
||||
// **offset:** How far the user has to scroll before the class is applied.
|
||||
export default function (options) {
|
||||
let $target = options.target || this;
|
||||
let {offset} = options;
|
||||
let className = options.className || 'scrolling';
|
||||
|
||||
if (this.scrollTop() > offset) {
|
||||
$target.addClass(className);
|
||||
} else {
|
||||
$target.removeClass(className);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue