Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
亚马逊的快速菜单
Search
sokamal
October 31, 2013
Programming
120
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
亚马逊的快速菜单
快速展开的菜单原理介绍,以及 jQuery-menu-aim 插件使用
sokamal
October 31, 2013
More Decks by sokamal
See All by sokamal
RETINA时代的前端优化
ikamal
2
190
jQuery最佳实践
ikamal
1
110
Less_css_介绍.pdf
ikamal
1
72
Other Decks in Programming
See All in Programming
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
220
Detecting Compromised CI with eBPF and Cilium Tetragon
lizrice
0
250
KotlinConf Extended South Korea 2026 Keynote
l2hyunwoo
0
120
Webエンジニアなのにブラウザの仕組みがわからないので、Pythonで自作してみた
tatsuki12
4
1k
私のClaude Code活用法 (個人開発編) - PHPerKaigi mini #4(2026/08/24)
panda_program
1
140
React本体のコードリーディング
high_g_engineer
1
150
Cloudflare is Agents
chimame
0
180
[PyCon KR 2026] More Variants, More Diversity for AI Accelerators
achimnol
0
110
My Marp Sample
sinoue0108
0
110
人間の目はかわらない、だからJPEGは30年もつ
yuzneri
12
19k
Discordを用いたラボオートメーション関連情報収集の自動化
noguhiro2002
0
400
AIと壁打ちしながら進めるコスト管理
fufuhu
2
1.6k
Featured
See All Featured
Optimizing for Happiness
mojombo
378
71k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3k
The Pragmatic Product Professional
lauravandoore
37
7.4k
Technical Leadership for Architectural Decision Making
baasie
3
520
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
260
A designer walks into a library…
pauljervisheath
211
24k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.8k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.8k
Transcript
亚马逊的快速菜单 算法及应用场景 -- 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