Foros del Web » Programando para Internet » Javascript »

[SOLUCIONADO] error en script

Estas en el tema de error en script en el foro de Javascript en Foros del Web. Buenas, alguien sabe por que en la línea 19 me da error? $pages.each (idx)-> saludos, y gracias! El codigo es el siguiente: bookClass = '.book' ...
  #1 (permalink)  
Antiguo 07/01/2017, 13:59
 
Fecha de Ingreso: junio-2014
Mensajes: 5
Antigüedad: 10 años, 5 meses
Puntos: 0
Exclamación error en script

Buenas,

alguien sabe por que en la línea 19 me da error? $pages.each (idx)->


saludos, y gracias!


El codigo es el siguiente:

bookClass = '.book'
pagesClass = '.pages'
pageClass = '.page'
pagesResponsiveClass = '.pages-responsive'
$pagesResponsive = $(pagesResponsiveClass)
$book = $(bookClass)
$pageContainer = $book.find(pagesClass)
$pages = $book.find(pageClass)
$prev = $('.prev')
$next = $('.next')
flipping = false
mouseX = 0
slideposition = 0
slidestart = false

currentPage = 0

$pagesLength = $pages.length
$pages.each (idx)->
if idx % 2 is 0
$(this).css('z-index', "#{$pagesLength - idx}")

$pageContainer.on 'click', pageClass, ->
$el = $(this)
if ($el.index() + 1) % 2 is 1
nextPage()
else
prevPage()

$pages.eq(currentPage).addClass('page--is-hoverable')

slidePage = (page=1)->
containerWidth = $pagesResponsive.width()
position = page * containerWidth
$pagesResponsive.animate({scrollLeft: position})


nextPage = (duration=500)->
return false if flipping
$pages.css 'transition-duration', "#{duration}ms"
# if not last page
if currentPage < $pagesLength - 1
$currentPage = $pages.eq(currentPage)
$currentPage.addClass('page--flipped')
$pages.eq(currentPage + 1).addClass('page--flipped')
$currentPage.removeClass('page--is-hoverable')
if currentPage isnt 0
$pages.eq(currentPage - 1).removeClass('page--is-hoverable')
flipping = true
slidePage(currentPage+2)
setTimeout ->
flipping = false
$pages.eq(currentPage + 1).addClass('page--is-hoverable')
$pages.eq(currentPage + 2).addClass('page--is-hoverable')
currentPage += 2
$pages.css 'transition-duration', "#{duration*1.2}ms"
, duration


prevPage = (duration=500)->
return false if flipping
$pages.css 'transition-duration', "#{duration}ms"
# if not first page
if currentPage > 0
$currentPage = $pages.eq(currentPage - 1)
$currentPage.removeClass('page--flipped')
$pages.eq(currentPage - 2).removeClass('page--flipped')
$pages.eq(currentPage).removeClass('page--is-hoverable')
$currentPage.removeClass('page--is-hoverable')
flipping = true
slidePage(currentPage-2)
setTimeout ->
flipping = false
$pages.eq(currentPage - 2).addClass('page--is-hoverable')
if currentPage > 2
$pages.eq(currentPage - 3).addClass('page--is-hoverable')
currentPage -= 2
$pages.css 'transition-duration', "duration*1.2ms"
, duration

seekPage = (page,duration=200) ->
if page != currentPage then slidePage(page)
if page % 2 isnt 0 then page++
if Math.abs(currentPage - page) < 3 then duration *= 2.5
if currentPage > page
prevPage(duration)
setTimeout ->
seekPage(page,duration)
, duration
else if currentPage < page
nextPage(duration)
setTimeout ->
seekPage(page,duration)
, duration
else
clearInterval(seekPage)


$('.pager').on 'click', 'a', (ev)->
ev.preventDefault()
$el = $(this)
page = $el.data('page')
seekPage page


$prev.on 'click', -> prevPage(500)
$next.on 'click', -> nextPage(500)

$pagesResponsive.on 'mouseup touchend', (ev)->
currentPosition = $pagesResponsive.scrollLeft()
containerWidth = $pagesResponsive.width()
page = Math.round(currentPosition / containerWidth) * containerWidth
$pagesResponsive.animate({scrollLeft: page})
slidestart = false

$pagesResponsive.on 'touchstart', ->
console.log 'touchstart'

$pagesResponsive.on 'touchmove', ->
console.log 'touchmove'

$pagesResponsive.on 'scroll', (ev)->
ev.preventDefault()

$pagesResponsive.on 'mousedown touchstart', (ev)->
ev.preventDefault()
slideposition = $(this).scrollLeft()
touch = ev.originalEvent.touches?[0];
if touch?
mouseX = touch.pageX
else
mouseX = ev.pageX
slidestart = true

$pagesResponsive.on 'mousemove touchmove', (ev)->
if slidestart
ev.preventDefault()
touch = ev.originalEvent.touches?[0];
if touch?
offsetX = touch.pageX - mouseX
else
offsetX = ev.pageX - mouseX

$(this).scrollLeft(slideposition - offsetX)

Etiquetas: scripts
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:17.