Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Removed unused "active" handling in <GhPostListItem>
Browse files Browse the repository at this point in the history
no issue

- "active" post list items no longer exist so we can remove the code related to handling the scroll-into-view and style changes
  • Loading branch information
kevinansfield committed Aug 27, 2019
1 parent 367419a commit a7aa74e
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 52 deletions.
45 changes: 1 addition & 44 deletions app/components/gh-posts-list-item.js
Expand Up @@ -10,14 +10,8 @@ export default Component.extend({

tagName: 'li',
classNames: ['gh-list-row', 'gh-posts-list-item'],
classNameBindings: ['active'],

post: null,
active: false,

// closure actions
onClick() {},
onDoubleClick() {},

isFeatured: alias('post.featured'),
isPage: alias('post.page'),
Expand Down Expand Up @@ -47,42 +41,5 @@ export default Component.extend({
} else {
return `${text.slice(0, 80)}...`;
}
}),

didReceiveAttrs() {
if (this.active) {
this.scrollIntoView();
}
},

click() {
this.onClick(this.post);
},

doubleClick() {
this.onDoubleClick(this.post);
},

scrollIntoView() {
let element = this.$();
let offset = element.offset().top;
let elementHeight = element.height();
let container = $('.content-list');
let containerHeight = container.height();
let currentScroll = container.scrollTop();
let isBelowTop, isAboveBottom, isOnScreen;

isAboveBottom = offset < containerHeight;
isBelowTop = offset > elementHeight;

isOnScreen = isBelowTop && isAboveBottom;

if (!isOnScreen) {
// Scroll so that element is centered in container
// 40 is the amount of padding on the container
container.clearQueue().animate({
scrollTop: currentScroll + offset - 40 - containerHeight / 2
});
}
}
})
});
6 changes: 0 additions & 6 deletions app/styles/layouts/content.css
Expand Up @@ -359,12 +359,6 @@
}
}

@media (min-width: 901px) {
.content-list .active a {
box-shadow: var(--blue) 3px 0 0 inset;
}
}


/* Empty State
/* ---------------------------------------------------------- */
Expand Down
1 change: 0 additions & 1 deletion app/templates/pages.hbs
Expand Up @@ -96,7 +96,6 @@
{{#each postsInfinityModel as |page|}}
{{gh-posts-list-item
post=page
onDoubleClick=(action "openEditor")
data-test-page-id=page.id}}
{{else}}
<li class="no-posts-box">
Expand Down
1 change: 0 additions & 1 deletion app/templates/posts.hbs
Expand Up @@ -96,7 +96,6 @@
{{#each postsInfinityModel as |post|}}
{{gh-posts-list-item
post=post
onDoubleClick=(action "openEditor")
data-test-post-id=post.id}}
{{else}}
<li class="no-posts-box">
Expand Down

0 comments on commit a7aa74e

Please sign in to comment.