From 117ab272229cc70a89e60197da47f9569df2a4b4 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Mon, 14 Dec 2015 17:56:22 +0000 Subject: [PATCH] Remove `setScrollClassName` mixin and usage no issue - removes `setScrollClassName` mixin that was previously used to add a `.scrolling` class to scrollable elements that showed a shadow at the top of boxes when not scrolled to the top --- .../components/gh-content-preview-content.js | 22 +------------------ core/client/app/components/gh-editor.js | 12 ---------- .../app/components/gh-infinite-scroll-box.js | 18 +-------------- core/client/app/mixins/ed-editor-scroll.js | 5 ----- core/client/app/utils/set-scroll-classname.js | 17 -------------- 5 files changed, 2 insertions(+), 72 deletions(-) delete mode 100644 core/client/app/utils/set-scroll-classname.js diff --git a/core/client/app/components/gh-content-preview-content.js b/core/client/app/components/gh-content-preview-content.js index c431ff8b4b..873a78ec62 100644 --- a/core/client/app/components/gh-content-preview-content.js +++ b/core/client/app/components/gh-content-preview-content.js @@ -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'); } }); diff --git a/core/client/app/components/gh-editor.js b/core/client/app/components/gh-editor.js index 2b86c240bd..d3824ac6d7 100644 --- a/core/client/app/components/gh-editor.js +++ b/core/client/app/components/gh-editor.js @@ -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: { diff --git a/core/client/app/components/gh-infinite-scroll-box.js b/core/client/app/components/gh-infinite-scroll-box.js index 22a4e8b5dc..25e61daeac 100644 --- a/core/client/app/components/gh-infinite-scroll-box.js +++ b/core/client/app/components/gh-infinite-scroll-box.js @@ -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'); - } }); diff --git a/core/client/app/mixins/ed-editor-scroll.js b/core/client/app/mixins/ed-editor-scroll.js index b56cacea94..5662098b11 100644 --- a/core/client/app/mixins/ed-editor-scroll.js +++ b/core/client/app/mixins/ed-editor-scroll.js @@ -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 - })); }, /** diff --git a/core/client/app/utils/set-scroll-classname.js b/core/client/app/utils/set-scroll-classname.js deleted file mode 100644 index fc2ba6b5d7..0000000000 --- a/core/client/app/utils/set-scroll-classname.js +++ /dev/null @@ -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); - } -}