All Projects β†’ rhanb β†’ nativescript-swipe-layout

rhanb / nativescript-swipe-layout

Licence: Apache-2.0 license
πŸŽ†

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects
shell
77523 projects
CSS
56736 projects

Projects that are alternatives of or similar to nativescript-swipe-layout

Nativescript Image Swipe
A NativeScript widget to easily πŸ‘† and πŸ” through a list of images
Stars: ✭ 35 (+66.67%)
Mutual labels:  swipe, nativescript
iron-swipeable-pages
[Polymer 1.x] Element that enables switching between different pages by swiping gesture.
Stars: ✭ 51 (+142.86%)
Mutual labels:  swipe
Fusuma
Multitouch gestures with libinput driver on Linux
Stars: ✭ 2,870 (+13566.67%)
Mutual labels:  swipe
nativescript-store-update
No description or website provided.
Stars: ✭ 18 (-14.29%)
Mutual labels:  nativescript
Reswipecard
a light lib for swipe the cards implemented by RecyclerView
Stars: ✭ 230 (+995.24%)
Mutual labels:  swipe
kikder-dating-swipe-app
❀️ Kik App, you know? πŸ’‘ Kikderβ„’ is a dating webapp that integrates the Kik, uses the HorOrNot game and the Tinder swipe. The F.A.S.T. Game Approach! The web app uses a custom lightweight MVC framework.
Stars: ✭ 21 (+0%)
Mutual labels:  swipe
Spstorkcontroller
Now playing controller from Apple Music, Mail & Podcasts Apple's apps.
Stars: ✭ 2,494 (+11776.19%)
Mutual labels:  swipe
react-native-segment-control
Swipeable SegmentedControl component for React Native apps
Stars: ✭ 21 (+0%)
Mutual labels:  swipe
nativescript-imagepicker
Imagepicker plugin supporting both single and multiple selection.
Stars: ✭ 103 (+390.48%)
Mutual labels:  nativescript
tailwind
Makes using TailwindCSS in NativeScript a whole lot easier!
Stars: ✭ 128 (+509.52%)
Mutual labels:  nativescript
nativescript-datetimepicker
Plugin with date and time picking fields
Stars: ✭ 26 (+23.81%)
Mutual labels:  nativescript
Swipycell
Easy to use UITableViewCell implementing swiping to trigger actions.
Stars: ✭ 230 (+995.24%)
Mutual labels:  swipe
NativeScript-Status-Bar
A simple NativeScript plugin for controlling status bar visibility.
Stars: ✭ 15 (-28.57%)
Mutual labels:  nativescript
React Native Swiper Flatlist
πŸ‘† Swiper component implemented with FlatList using Hooks & Typescript + strict automation tests with Detox
Stars: ✭ 217 (+933.33%)
Mutual labels:  swipe
MetalRecyclerPagerView
RecyclerView implementation for Android which makes it look and feel like ViewPager with item margins support (mutliple views effect).
Stars: ✭ 26 (+23.81%)
Mutual labels:  swipe
Slip
Slip.js β€” UI library for manipulating lists via swipe and drag gestures
Stars: ✭ 2,421 (+11428.57%)
Mutual labels:  swipe
Recordview
A Simple Audio Recorder View with "hold to Record Button" and "Swipe to Cancel " Like WhatsApp
Stars: ✭ 253 (+1104.76%)
Mutual labels:  swipe
RNSlidingButton
React Native Button component which support Slide event to perform action.
Stars: ✭ 19 (-9.52%)
Mutual labels:  swipe
nativescript-toolbox
A NativeScript module that is a composition of useful tools and helpers.
Stars: ✭ 54 (+157.14%)
Mutual labels:  nativescript
vue-product-carousel
Simple product carousel with hot image replacement, Zoom and Swipe mode
Stars: ✭ 37 (+76.19%)
Mutual labels:  swipe

Nativescript-swipe-layout

npm npm

NPM

Simple swipeable layout, which allow you to drag it, detect swipe events, and perform swipe animations.

Developed with ❀️ by the team NativeBaguette πŸ₯–

Installation

tns plugin add nativescript-swipe-layout

Usage

NativeScript with Angular

Here is an example of how you can use this plugin to build a tinder like stack of cards. Here, the plugin nativescript-cardview is used.

XML

app.component.html

<ActionBar title="swipe-layout" icon="" class="action-bar">
</ActionBar>
<GridLayout rows="*, auto" columns="*" backgroundColor="#77849F">
    <SwipeLayout *ngFor="let card of cards" row="0" colSpan="3" col="0" (loaded)="swipeLayoutLoaded($event)" (swipeDown)="swipeDownCallback($event)" (swipeUp)="swipeUpCallback($event)" [animationState]="swipeLayoutAnimated" [gestureMode]="gestureMode">
        <CardView width="300" height="300" backgroundColor="white" margin="10" elevation="40" radius="5">
            <GridLayout rows="200, auto" columns="*">
                <image [src]="card.img" stretch="aspectFill" colSpan="3" row="0"></image>
                <label [text]="card.test" class="info" textWrap="true" row="1" colSpan="3" class="p-20"></label>
            </GridLayout>
        </CardView>
    </SwipeLayout>
    <GridLayout row="1" rows="*" columns="auto, auto, auto">
        <Button (tap)="like()" row="0" col="0" class="p-20" class="btn btn-primary p-20" text="LIKE">
                </Button>
        <Button text="SUPER" (tap)="super()" row="0" col="1" class="btn p-20" backgroundColor="#5BD6BB" color="white"></Button>
        <Button text="DECLINE" (tap)="decline()" row="0" col="2" class="btn p-20" backgroundColor="#B33A3A" color="white"></Button>
    </GridLayout>
</GridLayout>

Component

app.component.ts

import { Component, ElementRef, ViewChild } from "@angular/core";
.
. // other imports
.
registerElement("CardView", () => CardView);
registerElement('SwipeLayout', () => SwipeLayout);

@Component({
    selector: "ns-app",
    templateUrl: "app.component.html",
})

export class AppComponent {
    private _swipeLayouts: Array<SwipeLayout>;
    private currentSwipeLayout: SwipeLayout;
    public swipeLayoutAnimated: ANIMATION_STATE;
    public gestureMode: GESTURE_MODE;

    public cards: Array<any> = [{ // dumb cards
        img: "https://img.youtube.com/vi/GGhKPm18E48/mqdefault.jpg",
        test: "Batman is pretty cool right?"
    },
    {
        img: "https://img.youtube.com/vi/GGhKPm18E48/mqdefault.jpg",
        test: "Batman is pretty cool right?"
    }, {
        img: "https://img.youtube.com/vi/GGhKPm18E48/mqdefault.jpg",
        test: "Batman is pretty cool right?"
    }, {
        img: "https://img.youtube.com/vi/GGhKPm18E48/mqdefault.jpg",
        test: "Batman is pretty cool right?"
    }, {
        img: "https://img.youtube.com/vi/GGhKPm18E48/mqdefault.jpg",
        test: "Batman is pretty cool right?"
    }, {
        img: "https://img.youtube.com/vi/GGhKPm18E48/mqdefault.jpg",
        test: "Batman is pretty cool right?"
    }]

    constructor(private fonticon: TNSFontIconService) {
        this._swipeLayouts = new Array();
        this.swipeLayoutAnimated = ANIMATION_STATE.ON_EVENTS; // Will animate only on swipe down and up events
        this.gestureMode = GESTURE_MODE.DRAG; // Cards will be draggable
    }

    swipeLayoutLoaded(event) {
        this._swipeLayouts.push(<SwipeLayout>event.object); // Since it's an Array everytime a SwipeLayout load we add it
    }

    ngAfterViewInit(): void {
        this.currentSwipeLayout = this._swipeLayouts[this._swipeLayouts.length - 1];
    }

    private next() {
        this._swipeLayouts.pop();
        this.currentSwipeLayout = this._swipeLayouts[this._swipeLayouts.length - 1];
    }
    
    swipeLeftCallback(swipeLeftEvent: SwipeLeftEventData) { // never called (not binded to the XML)
        console.log('swipeLeft');
        this.next();
    }

    swipeRightCallback(swipeRightEvent: SwipeRightEventData) { // never called (not binded to the XML)
        console.log('swipeRight');
        this.next();
    }
    
    swipeUpCallback(swipeUpEvent: SwipeUpEventData) { // called once the swipe up animation is done
        console.log('swipeUp');
        this.next();
    }
    
    swipeDownCallback(swipeDownEvent: SwipeDownEventData) { // called once the swipe down animation is done
        console.log('swipeDown');
        this.next();
    }

    decline() { // red button  on tap callback
        let that = this;
        this.currentSwipeLayout.animateSwipeRight().then(() => {
            that.next();
            console.log('swipeLeft done');
        });
    }


    like() { // blue button on tap callback
        let that = this;
        this.currentSwipeLayout.animateSwipeLeft().then(() => {
            that.next();
            console.log('swipeRight done');
        });
    }

    super() { // green button on tap callback
        let that = this;
        this.currentSwipeLayout.animateSwipeUp().then(() => {
            that.next();
            console.log("swipeUp done");
        });
    }
}

API

Further reading here.

Properties

Property Type Default Description
swipeRight function null Callback called when the layout is swiped to the right and the swipe animation is done.
swipeLeft function null Callback called when the layout is swiped to the left and the swipe animation is done.
swipeUp function null Callback called when the layout is swiped up and the swipe animation is done.
swipeDown function null Callback called when the layout is swiped down and the swipe animation is done.
animationState ANIMATION_STATE ANIMATION_STATE.ALWAYS Enable to perform animation when swipe events are fired, not at all or only on swipe events with a callback
gestureMode GESTURE_MODE GESTURE_MODE.SWIPE Allow to choose between the drag behavior or the swipe behavior

Methods

Method Return Parameters Description
animateSwipeRight Promise<void> None Method to manually start the swipe right animation.
animateSwipeLeft Promise<void> None Method to manually start the swipe left animation
animateSwipeUp Promise<void> None Method to manually start the swipe up animation
animateSwipeDown Promise<void> None Method to manually start the swipe down animation
swipe Promise<void> (swipeEvent: SwipeEventData) Method to manually start the swipe animation but has a parameter. From the direction given, will perform the right animation

All the method abose can be override, you can customise the animations as you want. If you wan't to override the animation which is performed on a swipe event you'll have to override the swipe method, since it's the one which is called when the event is fired πŸ”₯

NativeBaguette πŸ₯–

Rachid Al Kayat Jean-Baptiste Aniel triniwiz BradMartin JenLooper
rkhayyat rhanb triniwiz bradmartin jlooper
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].