Back to PhocacartRenderJs class

Method renderJsScrollTo

public static
renderJsScrollTo
(mixed $scrollTo = '', mixed $animation = 0)

Method renderJsScrollTo - Source code

public static function renderJsScrollTo($scrollTo = '', $animation = 0)
{
    $s[] = 'jQuery(function() {';
    $s[] = '   if (jQuery("#ph-msg-ns").length > 0){';
    $s[] = '      jQuery(document).scrollTop( jQuery("#system-message").offset().top );';
    //$s[] = '      jQuery(\'html,body\').animate({scrollTop: jQuery("#system-message").offset().top}, 1500 );';
    if ($scrollTo != '') {
        $s[] = '   } else {';
        if ($animation == 1) {
            $s[] = '	  jQuery(\'html,body\').animate({scrollTop: jQuery("#' . $scrollTo . '").offset().top}, 1500 );';
        } else {
            if ($animation == 2) {
                $s[] = '	  jQuery(\'html,body\').animate({scrollTop: jQuery("#' . $scrollTo . '").offset().top}, 1000 );';
            } else {
                $s[] = '      jQuery(document).scrollTop( jQuery("#' . $scrollTo . '").offset().top );';
            }
        }
    }
    $s[] = '   }';
    $s[] = '});';
    Factory::getDocument()->addScriptDeclaration(implode("\n", $s));
}