Skip to content

Commit

Permalink
Revert "fix: page scroll with URL hash redirection. (#4883)"
Browse files Browse the repository at this point in the history
This reverts commit 594d156.
  • Loading branch information
iamareebjamal authored Sep 4, 2020
1 parent 326e576 commit b8985a2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 27 deletions.
24 changes: 3 additions & 21 deletions app/components/public/side-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Component from '@ember/component';
import moment from 'moment';
import { SPEAKERS_FILTER } from 'open-event-frontend/routes/public/speakers';
import { tracked } from '@glimmer/tracking';
import $ from 'jquery';

@classic
export default class SideMenu extends Component {
Expand All @@ -14,19 +13,12 @@ export default class SideMenu extends Component {
@tracked
showSessions = false;

async didRender() {
super.didRender();
const anchor_tag = window.location.hash;
$('html, body').animate({
scrollTop: $(anchor_tag).offset().top
}, 20);
}

async didInsertElement() {
super.didInsertElement(...arguments);
const speakersCall = await this.event.speakersCall;
this.set('shouldShowCallforSpeakers',
speakersCall && speakersCall.announcement && (speakersCall.privacy === 'public'));

this.checkSpeakers();
this.checkSessions();
}
Expand Down Expand Up @@ -54,22 +46,12 @@ export default class SideMenu extends Component {
}

@action
scrollToTarget(e) {

if (history.pushState) {
history.pushState(null, null, e);
} else {
location.hash = e;
}
document.querySelector(e).scrollIntoView({
behavior: 'smooth', block: 'start'
});

scrollToTarget() {
document.querySelectorAll('.scroll').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth', block: 'start'
behavior: 'smooth'
});

document.querySelectorAll('.scroll').forEach(node => {
Expand Down
10 changes: 5 additions & 5 deletions app/templates/components/public/side-menu.hbs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{{#if (and (not-eq this.session.currentRouteName 'public.cfs.new-session') (not-eq this.session.currentRouteName 'public.cfs.new-speaker') (not-eq this.session.currentRouteName 'public.cfs.edit-speaker') (not-eq this.session.currentRouteName 'public.cfs.edit-session'))}}
<div class="ui fluid vertical {{unless this.device.isMobile 'pointing'}} menu">
{{#if (eq this.session.currentRouteName 'public.index')}}
<a href='#info' {{action "scrollToTarget" '#info'}} class='item active scroll'>
<a href='#info' {{action "scrollToTarget"}} class='item active scroll'>
{{t 'Info'}}
</a>
{{#if this.event.tickets.length}}
<a href='#tickets' {{action scrollToTarget '#tickets'}} class='item scroll'>
<a href='#tickets' {{action "scrollToTarget"}} class='item scroll'>
{{t 'Tickets'}}
</a>
{{/if}}
Expand Down Expand Up @@ -57,17 +57,17 @@
{{/if}}
{{#if this.event.hasOwnerInfo}}
{{#if (eq this.session.currentRouteName 'public.index')}}
<a href='#organizer' {{action scrollToTarget '#organizer'}} class='item scroll'>
<a href='#owner' {{action "scrollToTarget"}} class='item scroll'>
{{t 'Organizer'}}
</a>
{{else}}
<a class="item" href="{{href-to 'public.index'}}#organizer">
<a class="item" href="{{href-to 'public.index'}}#owner">
{{t 'Organizer'}}
</a>
{{/if}}
{{/if}}
{{#if (eq this.session.currentRouteName 'public.index')}}
<a href='#getting-here' {{action scrollToTarget '#getting-here'}} class='item scroll'>
<a href='#getting-here' class='item scroll'>
{{t 'Getting here'}}
</a>
{{else}}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/public/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<div class="ui hidden divider"></div>
{{/if}}
{{#if this.model.event.hasOwnerInfo}}
<h2 class="ui header" id="organizer">
<h2 class="ui header" id="owner">
{{t 'Organized by'}} {{this.model.event.ownerName}}
</h2>
{{sanitize this.model.event.ownerDescription}}
Expand Down

0 comments on commit b8985a2

Please sign in to comment.