rip out history pushstate
This commit is contained in:
parent
dab36da947
commit
2f76f2cac5
@ -32,9 +32,6 @@ class Attentive.Presentation
|
|||||||
@_slidesViewer ||= document.querySelector(@identifier)
|
@_slidesViewer ||= document.querySelector(@identifier)
|
||||||
|
|
||||||
start: ->
|
start: ->
|
||||||
if !this.isFile()
|
|
||||||
window.addEventListener('popstate', @handlePopState, false)
|
|
||||||
|
|
||||||
@timer.render()
|
@timer.render()
|
||||||
|
|
||||||
document.addEventListener('click', @handleClick, false)
|
document.addEventListener('click', @handleClick, false)
|
||||||
@ -57,15 +54,10 @@ class Attentive.Presentation
|
|||||||
imageWait()
|
imageWait()
|
||||||
|
|
||||||
slideFromLocation: ->
|
slideFromLocation: ->
|
||||||
value = if this.isFile()
|
Number(location.hash.substr(1))
|
||||||
location.hash
|
|
||||||
else
|
|
||||||
location.pathname
|
|
||||||
|
|
||||||
Number(value.substr(1))
|
|
||||||
|
|
||||||
handlePopState: (e) =>
|
handlePopState: (e) =>
|
||||||
this.advanceTo(if e.state then e.state.index else this.slideFromLocation())
|
this.advanceTo(this.slideFromLocation())
|
||||||
|
|
||||||
handleClick: (e) =>
|
handleClick: (e) =>
|
||||||
this.advance() if e.target.tagName != 'A'
|
this.advance() if e.target.tagName != 'A'
|
||||||
@ -89,18 +81,13 @@ class Attentive.Presentation
|
|||||||
advance: (offset = 1) =>
|
advance: (offset = 1) =>
|
||||||
this.advanceTo(Math.max(Math.min(@currentSlide + offset, @length - 1), 0))
|
this.advanceTo(Math.max(Math.min(@currentSlide + offset, @length - 1), 0))
|
||||||
|
|
||||||
isFile: => location.href.slice(0, 4) == 'file'
|
|
||||||
|
|
||||||
advanceTo: (index) =>
|
advanceTo: (index) =>
|
||||||
@priorSlide = @currentSlide
|
@priorSlide = @currentSlide
|
||||||
@currentSlide = index || 0
|
@currentSlide = index || 0
|
||||||
|
|
||||||
this.calculate()
|
this.calculate()
|
||||||
|
|
||||||
if this.isFile()
|
|
||||||
location.hash = @currentSlide
|
location.hash = @currentSlide
|
||||||
else
|
|
||||||
history.pushState({ index: @currentSlide }, '', @currentSlide)
|
|
||||||
|
|
||||||
calculate: =>
|
calculate: =>
|
||||||
if @currentWindowHeight != window.innerHeight
|
if @currentWindowHeight != window.innerHeight
|
||||||
|
Loading…
Reference in New Issue
Block a user