Skip to content
This repository was archived by the owner on Nov 17, 2019. It is now read-only.
This repository was archived by the owner on Nov 17, 2019. It is now read-only.

Called twice afterChange #5

Open

Description

Thanks for the plugin.
I had a problem. Called twice afterChange. I think it will be better. I added 'easeOutBack' to the animation and made a check before changing left.

// --------------- Update the position of the timeline ---------------
function _updateTimelinePos(callEvent) {
    var linePos = $el.find('.' + options.className + '-vertical-line').position().left;
    var activeDotPos = $el.find('.' + options.className + '-timeblock.active').position().left;
    var dotRadius = $el.find('.' + options.className + '-timeblock.active .' + options.className + '-dot').width() / 2;

    var diff = activeDotPos - linePos;
    var left;

    if (diff > 0) {
        left = '-' + (Math.abs(diff) + dotRadius + 1) +'';
    } else {
        left = '+' + (Math.abs(diff) - dotRadius - 1) +'';
    }

    var tl=$el.find('.' + options.className + '-timeline');
    if ($(tl).position().left != left) {
        $el.find('.' + options.className + '-timeline').stop().animate({
            left: left
        }, options.animationSpeed, 'easeOutBack', function() {
            if (typeof callEvent != 'undefined') {
                if (callEvent === 'click') {
                    var currYear = $el.find('.' + options.className + '-timeblock.active').first().attr('data-year');
                    hook('afterChange', [currYear]);
                }
                else if (callEvent === 'resize') hook('afterResize');
            }
        });
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions