|
365 | 365 | return (step && step.id && stepsData["impress-" + step.id]) ? step : null; |
366 | 366 | }; |
367 | 367 |
|
368 | | - var goto = function ( el, force ) { |
| 368 | + var goto = function ( el, duration ) { |
369 | 369 |
|
370 | | - if ( !initialized || !(el = getStep(el)) || (el === activeStep && !force) ) { |
371 | | - // selected element is not defined as step or is already active |
| 370 | + if ( !initialized || !(el = getStep(el)) ) { |
| 371 | + // presentation not initialized or given element is not a step |
372 | 372 | return false; |
373 | 373 | } |
374 | 374 |
|
|
409 | 409 | // check if the transition is zooming in or not |
410 | 410 | var zoomin = target.scale >= currentState.scale; |
411 | 411 |
|
412 | | - // if presentation starts (nothing is active yet) |
413 | | - // don't animate (set duration to 0) |
414 | | - var duration = (activeStep) ? config.transitionDuration : 0, |
415 | | - delay = (config.transitionDuration / 2); |
| 412 | + duration = toNumber(duration, config.transitionDuration); |
| 413 | + var delay = (duration / 2); |
416 | 414 |
|
417 | | - if (force) { |
| 415 | + if (el === activeStep) { |
418 | 416 | windowScale = computeWindowScale(config); |
419 | 417 | } |
420 | 418 |
|
|
486 | 484 | root.addEventListener("impress-init", function(){ |
487 | 485 | // HASH CHANGE |
488 | 486 |
|
| 487 | + var lastHash = ""; |
| 488 | + |
489 | 489 | // `#/step-id` is used instead of `#step-id` to prevent default browser |
490 | 490 | // scrolling to element in hash |
491 | 491 | // |
492 | 492 | // and it has to be set after animation finishes, because in Chrome it |
493 | 493 | // causes transtion being laggy |
494 | 494 | // BUG: http://code.google.com/p/chromium/issues/detail?id=62820 |
495 | 495 | root.addEventListener("impress-step-enter", function (event) { |
496 | | - window.location.hash = "#/" + event.target.id; |
| 496 | + window.location.hash = lastHash = "#/" + event.target.id; |
497 | 497 | }, false); |
498 | 498 |
|
499 | 499 | window.addEventListener("hashchange", function () { |
500 | | - goto( getElementFromUrl() ); |
| 500 | + // don't go twice to same element |
| 501 | + if (window.location.hash !== lastHash) { |
| 502 | + goto( getElementFromUrl() ); |
| 503 | + } |
501 | 504 | }, false); |
502 | 505 |
|
503 | 506 | // START |
504 | 507 | // by selecting step defined in url or first step of the presentation |
505 | | - goto(getElementFromUrl() || steps[0]); |
| 508 | + goto(getElementFromUrl() || steps[0], 0); |
506 | 509 | }, false); |
507 | 510 |
|
508 | 511 | body.classList.add("impress-disabled"); |
|
633 | 636 | // rescale presentation when window is resized |
634 | 637 | window.addEventListener("resize", throttle(function () { |
635 | 638 | // force going to active step again, to trigger rescaling |
636 | | - api.goto( document.querySelector(".active"), true ); |
| 639 | + api.goto( document.querySelector(".active"), 500 ); |
637 | 640 | }, 250), false); |
638 | 641 |
|
639 | 642 | }, false); |
|
0 commit comments