提交 f957ad84 编写于 作者: M Minwe

update ScrollSpyNav; update dropdown demo

上级 de465e30
......@@ -38,6 +38,10 @@ __Sticky__:
- `NEW` 增加 `media` 选项,可以设置 Media Query;
- `NEW` 增加 `bottom` 选项。
__ScrollSpyNav__:
- `FIXED` 链接点击失效问题。
__Popover__
- `IMPROVED` 每次打开时重新计算弹出层的位置,减少位置偏移问题;
......
......@@ -193,17 +193,25 @@
$(function() {
var $dropdown = $('#doc-dropdown-js'),
data = $dropdown.data('amui.dropdown');
function scrollToDropdown() {
$(window).smoothScroll({position: $dropdown.offset().top});
}
$('#doc-dropdown-toggle').on('click', function(e) {
scrollToDropdown();
$dropdown.dropdown('toggle');
return false;
});
$('#doc-dropdown-open').on('click', function(e) {
scrollToDropdown();
data.active ? alert('已经打开了,施主又何必再纠缠呢!') : $dropdown.dropdown('open');
return false;
});
$('#doc-dropdown-close').on('click', function(e) {
scrollToDropdown();
data.active ? $dropdown.dropdown('close') : alert('没有开哪有关,没有失哪有得!');
return false;
});
......
define(function(require, exports, module) {
'use strict';
require('core');
require('ui.smooth-scroll');
var $ = window.Zepto,
UI = $.AMUI;
......@@ -33,7 +32,7 @@ define(function(require, exports, module) {
this.$window = $(window).on('scroll.scrollspynav.amui', processRAF)
.on('resize.scrollspynav.amui orientationchange.scrollspynav.amui', UI.utils.debounce(processRAF, 50));
processRAF();
processRAF();
this.scrollProcess();
};
......@@ -91,18 +90,15 @@ define(function(require, exports, module) {
// smoothScroll
if (this.options.smooth) {
require.async(['ui.smooth-scroll'], function() {
$links.on('click', function(e) {
e.preventDefault();
$links.on('click', function(e) {
e.preventDefault();
var $this = $(this),
target = $this.attr('href'),
position = $this.data('am.smoothScroll');
var $this = $(this),
$target = $($this.attr('href'));
!position && $this.data('am.smoothScroll', (position = $(target).offset().top));
if (!$target) return;
$(window).smoothScroll(position);
});
$(window).smoothScroll({position: $target.offset().top});
});
}
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册