Skip to content

Commit

Permalink
fix: Removing ember-scroll-to addon (#3852)
Browse files Browse the repository at this point in the history
* add custom scroll action for side-menu

* remove ember-scroll-to

* remove jQuery

Co-authored-by: Kush Trivedi <44091822+kushthedude@users.noreply.github.com>
  • Loading branch information
snitin315 and kushthedude authored Feb 7, 2020
1 parent 498bc7b commit 3a8d169
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
17 changes: 17 additions & 0 deletions app/components/public/side-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@ export default Component.extend({
this.set('shouldShowCallforSpeakers',
speakersCall && speakersCall.announcement && (speakersCall.privacy === 'public'));
},
actions: {
scrollToTarget() {
document.querySelectorAll('.scroll').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});

document.querySelectorAll('.scroll').forEach(node => {
node.classList.remove('active');
});
e.target.classList.add('active');
});
});
}
},
isSchedulePublished: computed('event.schedulePublishedOn', function() {
return this.get('event.schedulePublishedOn') && this.get('event.schedulePublishedOn').toISOString() !== moment(0).toISOString();
})
Expand Down
16 changes: 8 additions & 8 deletions app/templates/components/public/side-menu.hbs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{{#if (and (not-eq session.currentRouteName 'public.cfs.new-session') (not-eq session.currentRouteName 'public.cfs.new-speaker') (not-eq session.currentRouteName 'public.cfs.edit-speaker') (not-eq session.currentRouteName 'public.cfs.edit-session'))}}
<div class="ui fluid vertical {{unless device.isMobile 'pointing'}} menu">
{{#if (eq session.currentRouteName 'public.index')}}
{{#scroll-to href='#info' class='item active'}}
<a href='#info' {{action "scrollToTarget"}} class='item active scroll'>
{{t 'Info'}}
{{/scroll-to}}
</a>
{{#if event.tickets.length}}
{{#scroll-to href='#tickets' class='item'}}
<a href='#tickets' {{action "scrollToTarget"}} class='item scroll'>
{{t 'Tickets'}}
{{/scroll-to}}
</a>
{{/if}}
{{#if event.speakers.length}}
{{#link-to 'public.speakers' class='item'}}
Expand Down Expand Up @@ -46,19 +46,19 @@
{{/if}}
{{#if event.hasOwnerInfo}}
{{#if (eq session.currentRouteName 'public.index')}}
{{#scroll-to href='#owner' class='item'}}
<a href='#owner' {{action "scrollToTarget"}} class='item scroll'>
{{t 'Owner'}}
{{/scroll-to}}
</a>
{{else}}
<a class="item" href="{{href-to 'public.index'}}#owner">
{{t 'Owner'}}
</a>
{{/if}}
{{/if}}
{{#if (eq session.currentRouteName 'public.index')}}
{{#scroll-to href='#getting-here' class='item'}}
<a href='#getting-here' class='item scroll'>
{{t 'Getting here'}}
{{/scroll-to}}
</a>
{{else}}
<a class="item" href="{{href-to 'public.index'}}#getting-here">
{{t 'Getting here'}}
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
"ember-resolver": "^7.0.0",
"ember-route-action-helper": "^2.0.8",
"ember-router-scroll": "^2.0.0",
"ember-scroll-to": "^0.6.5",
"ember-simple-auth": "^2.1.1",
"ember-simple-auth-token": "^4.0.7",
"ember-source": "~3.16.1",
Expand Down
7 changes: 0 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6961,13 +6961,6 @@ ember-runtime-enumerable-includes-polyfill@^2.0.0:
ember-cli-babel "^6.9.0"
ember-cli-version-checker "^2.1.0"

ember-scroll-to@^0.6.5:
version "0.6.5"
resolved "https://registry.yarnpkg.com/ember-scroll-to/-/ember-scroll-to-0.6.5.tgz#d9a7658eed6b8ae0e3c71b93b03f59a8550b8a10"
dependencies:
ember-cli-babel "^6.3.0"
ember-cli-htmlbars "^2.0.1"

ember-simple-auth-token@^4.0.7:
version "4.0.7"
resolved "https://registry.yarnpkg.com/ember-simple-auth-token/-/ember-simple-auth-token-4.0.7.tgz#df4177d118b9f7a75a3879ceec04ab2c55e1cad2"
Expand Down

0 comments on commit 3a8d169

Please sign in to comment.