All Projects → mzule → Fantasyslide

mzule / Fantasyslide

Licence: apache-2.0
Another sliding menu base on DrawerLayout

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Fantasyslide

Drawer Behavior Flutter
Drawer behavior is a library that provide an extra behavior on drawer, such as, move view or scaling view's height while drawer on slide.
Stars: ✭ 110 (-92.31%)
Mutual labels:  sidebar, drawerlayout
WaveSideBar
Animated side bar view
Stars: ✭ 38 (-97.34%)
Mutual labels:  menubar, sidebar
Vue Drawer Layout
A simple DrawerLayout component for Vue.js.
Stars: ✭ 392 (-72.61%)
Mutual labels:  sidebar, drawerlayout
Chromenu
Mobile Chrome in your menubar
Stars: ✭ 44 (-96.93%)
Mutual labels:  menubar
Latexcv
👔 A collection of cv and resume templates written in LaTeX. Leave an issue if your language is not supported!
Stars: ✭ 1,027 (-28.23%)
Mutual labels:  sidebar
Icointicker
macOS crypto currency menubar ticker (맥 가상화폐 시세 메뉴바 티커)
Stars: ✭ 70 (-95.11%)
Mutual labels:  menubar
Overlaycontroller
OverlayController easily pop your custom view and provide optional transition animation. written in swift 5.0
Stars: ✭ 94 (-93.43%)
Mutual labels:  sidebar
Uiutil
UIUtil for Android, Lyrics, Tick animations, Comparisons, Satellite menus, Praise, Slide buttons, TAB indicators, Contact sorting, Drag sorting, Skidding deletes, Shadow effects, RecyclerView nesting RecyclerView, Map list Poi/Drawer effects, Progress settings, Clock set, Damping, Progress, Album, Snap, Progress, CircleDownload, AdvertSwitcher, Carousel ad, FlowLayout, Tag...; 歌词控件、打勾动画、对比、卫星菜单、点赞、滑动按钮、TAB指示器、联系人排序、拖曳排序、侧滑删除、阴影效果.、RecyclerView嵌套RecyclerView.、地图列表Poi/抽屉效果、进度设置、时钟设置、滑动阻尼、相册媒体快照、圆形下载进度,轮播广告, 流式布局,标签...
Stars: ✭ 1,018 (-28.86%)
Mutual labels:  sidebar
Tab Stash
Firefox extension to save and restore tabs as bookmarks
Stars: ✭ 86 (-93.99%)
Mutual labels:  sidebar
Air
Mac menu bar app to track Air Quality
Stars: ✭ 63 (-95.6%)
Mutual labels:  menubar
Ngsplitmenucontroller
Menu Driven Split view controller
Stars: ✭ 61 (-95.74%)
Mutual labels:  menubar
Google Search Sidebar
A user script and user style to move Google search tools to sidebar.
Stars: ✭ 46 (-96.79%)
Mutual labels:  sidebar
Menubar Brightness
MacOS app to change the screen brightness on the menubar.
Stars: ✭ 77 (-94.62%)
Mutual labels:  menubar
Electron Menubar
🌟Sample menubar app that shows popover for macOS
Stars: ✭ 44 (-96.93%)
Mutual labels:  menubar
Container Tabs Sidebar
Firefox addon aiming to utilize screen estate more efficiently by showing tabs in a sidebar grouped by privacy containers. Inspired by TreeStyleTab.
Stars: ✭ 87 (-93.92%)
Mutual labels:  sidebar
Nly Adminlte Vue
vuejs2 AdminLte3 template more than 50 components and 10 directives.such as collapse ,sidebar,container,infobox,breadcrumb,card,grid,dropdown,toast,navbar,timeline,icon,progress
Stars: ✭ 44 (-96.93%)
Mutual labels:  sidebar
Yndropdownmenu
✨ Awesome Dropdown menu for iOS with Swift 5.0
Stars: ✭ 1,259 (-12.02%)
Mutual labels:  menubar
Slideout
A touch slideout navigation menu for your mobile web apps.
Stars: ✭ 7,981 (+457.72%)
Mutual labels:  sidebar
Floatsidebar.js
Lightweight (2kb gzipped), zero-dependency javascript library for making float sidebars based on the finite state machine
Stars: ✭ 56 (-96.09%)
Mutual labels:  sidebar
Wip Menubar
🚧 WIP Menubar
Stars: ✭ 65 (-95.46%)
Mutual labels:  menubar

FantasySlide

DOWNLOAD API Android Arsenal

一个 DrawerLayout 的扩展,具有帅气的动画与创新的交互。一次手势完成滑出侧边栏与选择菜单。欢迎下载 demo 体验。

https://raw.githubusercontent.com/mzule/FantasySlide/master/demo.apk

效果

使用方法

添加依赖

compile 'com.github.mzule.fantasyslide:library:1.0.5'

调用

调用方法基本与 DrawerLayout 一致. 本项目支持左右 (start left end right) 侧边栏同时定义。

<com.github.mzule.fantasyslide.FantasyDrawerLayout xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop"
        android:src="@drawable/fake" />

    <com.github.mzule.fantasyslide.SideBar
        android:id="@+id/leftSideBar"
        android:layout_width="200dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@color/colorPrimary"
        app:maxTranslationX="66dp">
        
        <!-- 这里是 SideBar 的子视图-->
        
    </com.github.mzule.fantasyslide.SideBar>
    <!-- 如果需要的话,可以添加右侧边栏-->
</com.github.mzule.fantasyslide.FantasyDrawerLayout>
  1. 最外层的 FantasyDrawerLayout 的使用与官方的 DrawerLayout 完全一致。
  2. SideBar 用来包装每一个菜单项,SideBar 本质上可以当做一个 vertical 的 LinearLayout 来使用。
  3. 效果图上的文字变色是表示该菜单处于 hover 状态, hover 状态默认会设定 view 的 pressed 状态为 true。可以通过 Listener 来改写, 下文会有详细说明。
  4. 详细参考 https://github.com/mzule/FantasySlide/blob/master/app/src/main/res/layout/activity_main.xml

进阶

maxTranslationX

通过设置 maxTranslationX 可以设置菜单项动画的最大位移。仅有在采用默认 Transformer 时才有效。

<com.github.mzule.fantasyslide.SideBar
	...
    app:maxTranslationX="88dp">

一般情况下,左边的侧边栏 maxTranslationX 为正数,右边的侧边栏 maxTranslationX 为负数。

Listener

支持设置 Listener 来监听侧边栏菜单的状态。

SideBar leftSideBar = (SideBar) findViewById(R.id.leftSideBar);
leftSideBar.setFantasyListener(new SimpleFantasyListener() {
    @Override
    public boolean onHover(@Nullable View view) {
    	return false;
    }

    @Override
    public boolean onSelect(View view) {
        return false;
    }

    @Override
    public void onCancel() {
    }
});
  1. Hover 是指上面效果图中,高亮的状态,此时手指仍在屏幕上 move. 默认的 hover 处理逻辑是设置 view 的 pressed 状态为 true. 重写 onHover(View) 方法返回 true 可以改写默认逻辑。
  2. Select 是指 hover 状态时手指离开屏幕,触发 select 状态。默认的处理逻辑是调用 view 的 onClick 事件。重写 onSelect(View) 方法返回 true 可以改写默认逻辑。
  3. Cancel 是指手指离开屏幕时,没有任何 view 触发 select 状态,则为 cancel,无默认处理逻辑。

Transformer

项目设计了一个 Transformer 接口,供调用者自定义菜单项的动画效果。使用方法类似于 ViewPager 的 PageTransformer.

class DefaultTransformer implements Transformer {
    private float maxTranslationX;

    DefaultTransformer(float maxTranslationX) {
        this.maxTranslationX = maxTranslationX;
    }

    @Override
    public void apply(ViewGroup sideBar, View itemView, float touchY, float slideOffset, boolean isLeft) {
        float translationX;
        int centerY = itemView.getTop() + itemView.getHeight() / 2;
        float distance = Math.abs(touchY - centerY);
        float scale = distance / sideBar.getHeight() * 3; // 距离中心点距离与 sideBar 的 1/3 对比
        if (isLeft) {
            translationX = Math.max(0, maxTranslationX - scale * maxTranslationX);
        } else {
            translationX = Math.min(0, maxTranslationX - scale * maxTranslationX);
        }
        itemView.setTranslationX(translationX * slideOffset);
    }
}

感谢

动画效果参考自 dribbble. https://dribbble.com/shots/2269140-Force-Touch-Slide-Menu 在此感谢。

另外,demo 里面 MainActivity 的右边栏实现了类似原作的菜单动画效果。具体可以参考相关代码。

许可

Apache License 2.0

联系我

任何相关问题都可以通过以下方式联系我。

  1. 提 issue
  2. 新浪微博 http://weibo.com/mzule
  3. 个人博客 https://mzule.github.io/
  4. 邮件 "mzule".concat("4j").concat("@").concat("gmail.com")
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].