관리자 페이지 앵커 스크립트 적용

This commit is contained in:
thisgun committed 2017-10-24 17:52:49 +09:00
1 parent 8a5b733d92
commit 1b37f8b4e7
2 files changed
+80

No files matched your search

+15
View File
@@ -29,8 +29,23 @@ $(".scroll_top").click(function(){
<!-- <p>실행시간 : <?php echo get_microtime() - $begin_time; ?> -->
<script src="<?php echo G5_ADMIN_URL ?>/admin.js?ver=<?php echo G5_JS_VER; ?>"></script>
<script src="<?php echo G5_JS_URL ?>/jquery.anchorScroll.js?ver=<?php echo G5_JS_VER; ?>"></script>
<script>
$(function(){
var admin_head_height = $("#hd_top").height() + $("#container_title").height() + 5;
$("a[href^='#']").anchorScroll({
scrollSpeed: 0, // scroll speed
offsetTop: admin_head_height, // offset for fixed top bars (defaults to 0)
onScroll: function () {
// callback on scroll start
},
scrollEnd: function () {
// callback on scroll end
}
});
var hide_menu = false;
var mouse_event = false;
var oldX = oldY = 0;
+65
View File
@@ -0,0 +1,65 @@
/*!
* jQuery.anchorScroll jQuery Plugin v1.0
*
* Author: Virgiliu Diaconu
* http://www.virgiliu.com
* Licensed under the MIT license.
*/
;
(function($, window, document, undefined) {
'use strict';
$.anchorScroll = function(el, options) {
var base = this;
// Access to jQuery and DOM versions of element
base.$el = $(el);
base.el = el;
base.init = function() {
base.options = $.extend({}, $.anchorScroll.defaultOptions, options);
};
// On click
base.$el.click(function(e) {
e.preventDefault();
if ($(e.target).closest('a').length && $(base.el.hash).length) {
var targetPos = $(base.el.hash).offset().top - base.options.offsetTop,
classTo = (base.$el.data("classTo") === "this") ? base.el : base.$el.data("classTo"),
onScroll = base.$el.data("onScroll"),
scrollEnd = base.$el.data("scrollEnd");
// Callback scroll start
if (typeof base.options.scrollStart === 'function') {
base.options.scrollStart.call(el);
}
// Add class to element on scroll
$(classTo).addClass(onScroll).removeClass(scrollEnd);
// Smooth scroll
$('html,body').animate({
scrollTop: targetPos
}, base.options.scrollSpeed).promise().done(function() {
// On animation complete
$(classTo).addClass(scrollEnd).removeClass(onScroll);
// Callback on scroll end
if (typeof base.options.scrollEnd === 'function') {
base.options.scrollEnd.call(el);
}
});
}
});
// Run initializer
base.init();
};
$.anchorScroll.defaultOptions = {
scrollSpeed: 800,
offsetTop: 0
};
$.fn.anchorScroll = function(options) {
return this.each(function() {
(new $.anchorScroll(this, options));
});
};
})(jQuery, window, document);