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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
71
Other Decks in Programming
See All in Programming
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
3.9k
軽量Java基盤の設計 DIコンテナに頼らない、長期保守と1秒起動の実現 JJUG CCC 2026 Spring
macha64
0
510
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
0
230
Creating Composable Callables in Contemporary C++
rollbear
0
120
Mujeres en SEO Summit 2026 - Greatest Disaster Hits en Web Performance
guaca
0
170
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
280
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
190
Claspは野良GASの夢をみるか
takter00
0
190
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
5.8k
Vite+ Unified Toolchain for the Web
naokihaba
0
300
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
170
Javaの型とAI時代に型が大事な理由 / java types and type in AI era
kishida
2
130
Featured
See All Featured
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
310
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
230
Abbi's Birthday
coloredviolet
2
8k
Fireside Chat
paigeccino
42
3.9k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
3.4k
Chasing Engaging Ingredients in Design
codingconduct
0
220
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
230
Thoughts on Productivity
jonyablonski
76
5.2k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
350
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.1k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
160
The Curious Case for Waylosing
cassininazir
1
390
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