Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
亚马逊的快速菜单
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
sokamal
October 31, 2013
Programming
130
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
亚马逊的快速菜单
快速展开的菜单原理介绍,以及 jQuery-menu-aim 插件使用
sokamal
October 31, 2013
Transcript
15 slides
亚马逊的快速菜单 算法及应用场景 -- ECD kamalyu
上下移动--快速切换
斜向二级菜单移动--延时收起当前二级菜单 http://www.amazon.cn/
jQuery-menu-aim https://github.com/kamens/jQuery-menu-aim .menuAim({ activate: function() {}, deactivate: function() {}, enter:
function() {}, exit: function() {}, exitMenu: function() {}, rowSelector: "> li",... // "left", "above", or "below". Defaults to "right". submenuDirection: "right" });
服务平台的例子 $menu.menuAim({ // 一级菜单 rowSelector: "[data-menuid]", // 激活菜单 activate:activateSubmenu, //
取消激活 deactivate:deactivateSubmenu // 离开整个菜单区域 ,exitMenu:exitAllMenu });
实现原理 $menu .mouseleave(mouseleaveMenu) .find(options.rowSelector) .mouseenter(mouseenterRow) .mouseleave(mouseleaveRow) .click(clickRow);
实现原理 menuRow.mouseenter(mouseenterRow) // (可能)绑定延时函数 menuRow.click(clickRow) // 立即active当前一级菜单 menuRow.mouseleave(mouseleaveRow) // 删除延时函数
mouseleave(mouseleaveMenu) // 删除延时函数,调用离开菜单区域的回调函 数
mouseenterRow possiblyActivate 计算activeDelay , 插件的核心算法部分 如果 delay>0 就设置延时再调用 possiblyActivate
核心算法 activeDelay() 如果当前没有展开的二级分类,返回 0; 如果是从菜单区域之外进入,返回 0; 如果鼠标静止不动,返回 0; 计算轨迹,如果朝向二级菜单,返回 delay;
如果没有朝向二级菜单,返回 0;
鼠标轨迹计算 一个FIFO的对象,始终记录鼠标最后三个坐标; 取第一个和第三个做对比,推断运动方向;
鼠标轨迹计算 简化一下 C-B1 C-A1 ------- < -------- B-B1 A-A1
鼠标轨迹计算 上方同理 D-B1 D-A1 ------- < -------- B-B1 A-A1 上下左右方向都可以由相同的公式
计算
适用场景 一级菜单比较宽
不适用场景 一级菜单比较短 此时直接给每个菜单加适当的延时更合适 鼠标进入另外一个一级菜单的瞬间,不一定朝向二级菜单方向
Thank you
More Decks by sokamal
See All by sokamal
RETINA时代的前端优化
ikamal
2
200
jQuery最佳实践
ikamal
1
110
Less_css_介绍.pdf
ikamal
1
78
Other Decks in Programming
See All in Programming
DroidKnights 2026 Android A2UI Jetpack Compose 기반의 안전한 AI UI 렌더링 - 박제창
itsmedreamwalker
1
260
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
1
220
How SRE Grew Out of Server-Side Work and Became the Team's Own / サーバサイドから始まったSREを チームに渡すまで
maaaato
0
210
Kotlin JVM用に作られたライブラリのKMPを前提とした再設計
jsoizo
0
230
AIエージェントの「テストは通るのに本番で壊れる」を減らす
shibuiwilliam
3
120
Skills Are the New npm [AAIF Bengaluru]
shivamsaraswat
0
120
手の動かし方がわからなかった私が個人開発者になるまで
usagi0920_pochi
0
340
Beyond Chatbots: Agentic UI with Open Standards @W-JAX 2026, München
manfredsteyer
PRO
0
130
どうしても Eloquent でリポジトリパターンをやりたいんだ #phpcon_niigata / phpcon-niigata-2026
shogogg
0
670
はじめてのKubernetesコントリビューション
nasa9084
0
320
プロジェクトコードをキレイキレイしよう!暗黙的な参照を読み解く静的解析
ostk0069
0
220
AI駆動TDD ― 2026年10月版
hrmstrsmgs
0
110
Featured
See All Featured
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
630
Code Reviewing Like a Champion
maltzj
529
40k
Visualization
eitanlees
153
17k
The Cost Of JavaScript in 2023
addyosmani
56
10k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.6k
The Invisible Side of Design
smashingmag
301
52k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.5k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
790
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Site-Speed That Sticks
csswizardry
13
1.6k
Making the Leap to Tech Lead
cromwellryan
135
10k
How to Ace a Technical Interview
jacobian
280
24k