html插件多级侧边栏,非常不错多种效果侧边栏插件ember-burger-menu

侧边栏插件ember-burger-menu是一个可以从网页的左侧或者右侧滑动显示侧边栏的 插件,菜单可以通过设置从网页的左侧或者右侧以动画的形式滑动显示出来。适用于移动设备侧边栏菜单的显示和隐藏。并且支持键盘的 Esc 键隐藏菜单。

bfa2a44ce84a0df4d60a0d2fe9627de9.png

非常不错多种效果侧边栏插件ember-burger-menu,slide、reveal、push、fall-down、open-door、push-rotate、rotate-out、scale-up、scale-down、scale-rotate、slide-reverse、slide-shrink

Animations

Menu Animations

slide

reveal

push

fall-down

open-door

push-rotate

rotate-out

scale-up

scale-down

scale-rotate

slide-reverse

slide-shrink

Menu Item Animations

push

stack

Usage

This addon utilizes contextual components to be able to correctly control and animate necessary elements.

{{#burger-menu as |burger|}} {{#burger.menu itemTagName="li" as |menu|}} Close

  • {{#menu.item}} {{link-to 'Features' 'features'}} {{/menu.item}} {{#menu.item}} {{link-to 'About' 'about'}} {{/menu.item}} {{#menu.item}} {{link-to 'Contact Us' 'contact'}} {{/menu.item}}
{{/burger.menu}} {{#burger.outlet}} Menu {{outlet}} {{/burger.outlet}} {{/burger-menu}}

Components

{{burger-menu}}

Options

open

The current open state of the menu.

Default: false

animation

The menu animation. See Animations for the list of available animations.

Default: slide

itemAnimation

The menu item animation. See Item Animations for the list of available item animations.

Default: null

position

The menu's open position. Can either be left or right

Default: left

width

The menu's width (in px).

Default: 300

locked

Lock the menu in its current open / closed state. Please note that changes made

directly via the burgerMenu service or {{burger.state.actions}} will still propagate.

Default: false

customAnimation

Override of the menu's styles with your own implementation. See Custom Animations for more details.

translucentOverlay

Whether the outlet has a translucent overlay over it once the menu is opened.

Default: true

dismissOnClick

Whether the menu can be dismissed when clicking outside of it.

Default: true

dismissOnEsc

Whether the menu can be closed when pressing the ESC key.

Default: true

gesturesEnabled

Whether the menu can be open / closed using gestures. The only available gesture currently is swipe.

Default: true

minSwipeDistance

The minimum distance (in px) the user must swipe to register as valid.

Default: 150

maxSwipeTime

The maximum amount of time (in ms) it must take the user to swipe to be registered as valid .

Default: 300

{{burger.outlet}}

This component is where all your content should be placed.

{{burger.menu}}

Everything rendered here will be inside the menu.

Options

itemTagName

The default tagName that will be used by the {{menu.item}} component.

Default: div

dismissOnItemClick

Close the menu on click of a {{menu.item}}.

Default: false

Actions

onOpen

Triggered when the menu is opening

onClose

Triggered when the menu is closing

{{menu.item}}

The individual menu item. This is required if you have specified an itemAnimation.

Options

dismissOnClick

Close the menu on click.

Default: false

The Menu State

Via Component

The {{burger-menu}} component exposes multiple

contextual components, but it also exposes a state object which allows

you to control the state of the menu.

{{#burger-menu as |burger|}} {{#burger.outlet}} {{/burger.outlet}} {{/burger-menu}}

Via Service

If you need a more programmatic solution, you can grab the menu state via injecting the burgerMenu service.

export default Ember.Component.extend({

burgerMenu: Ember.inject.service()

})

Usage

You can use the menu state object to modify pretty much any property.

open

width

position

animation

itemAnimation

customAnimation

burgerMenu.set('width', 500); burgerMenu.toggleProperty('open');

The state object also exposes some actions.

open

Open

close

Close

toggle

Toggle

Custom Animations

If you're not impressed with the in-house animations and want to

create your own, all you have to do is pass the following class to the customAnimation property in the {{burger-menu}} component. If you think your animation would be a good addition to the existing collection, feel free to open a PR with it!

import Animation from 'ember-burger-menu/animations/base'; export default Animation.extend({ // CSS class names to be able to target our menu animation: 'my-custom-animation',

itemAnimation: 'my-custom-item-animation', container(open, width, right) { return {};

}, outlet(open, width, right) { return {

transform: open ? right ? `translate3d(-${width}px, 0, 0)` : `translate3d(${width}px, 0, 0)` : '' };

}, menu(open, width, right) { return {};

}, menuItem(open, width, right, index) { return {

transform: open ? '' : `translate3d(0, ${(index + 1) * 500}px, 0)` };

}

});

Note: You don't need to worry about prefixing your CSS attributes as it will be done for you.

If you need to add some base CSS to your animation, you can target the menu as such:

.ember-burger-menu.bm--my-custom-animation { .bm-menu {} .bm-outlet {} &.is-open { .bm-menu {} .bm-outlet {}

}

}

And the menu items as such:

.ember-burger-menu { .bm-menu.bm-item--my-custom-item-animation { .bm-menu-item {}

} &.is-open { .bm-menu.bm-item--my-custom-item-animation { .bm-menu-item {}

}

}

}

To use our new custom animation, all we have to do is pass the class to

the customAnimation option in the {{burger-menu}} component.

import MyCustomAnimation from 'path/to/my-custom-animation'; export default Ember.Component.extend({

MyCustomAnimation

});

{{#burger-menu customAnimation=MyCustomAnimation}} ... {{/burger-menu}}

相关链接

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值