Skip to content

Commit

Permalink
Changes setInterval into onpopstate
Browse files Browse the repository at this point in the history
 - removed console log and clearInterval from hide()
  • Loading branch information
JV Estolas committed May 22, 2017
1 parent f019e75 commit d67c20a
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ class Picker {

// Hide.
hide() {
// clear interval when datepicker is hides.
clearInterval(compareHrefInterval);

this.container.setAttribute(`data-open`, this.isOpen = false);
// Close the picker when clicking outside of a date input or picker.
if(this.input) { this.input.blur() }
Expand All @@ -135,13 +132,9 @@ class Picker {

// when used in a single-page app or otherwise,
// hide datepicker when the browser's back button is pressed
let currentPage = window.location.href;
compareHrefInterval = setInterval(() => {
console.log('in setinterval');
if (currentPage != window.location.href) {
thePicker.hide();
}
}, 100);
window.onpopstate = () => {
this.hide();
}
}

// Position picker below element. Align to element's right edge.
Expand Down

0 comments on commit d67c20a

Please sign in to comment.