Git Product home page Git Product logo

left-swipe-action's Introduction

<left-swipe-action>

Polymer Web Component <left-swipe-action>

<left-swipe-action> is built with Polymer to enables a left swipe gesture to open a content and show behind action buttons like iOS item list.

This component wraps your own element and the wrapper handles gesture events. The main content will be opened by a left swipe and specified buttons <left-swipe-action-button> will be shown behind of the content. The other gestures on the component will close the content.

<left-swipe-action>
    <div>
        <!-- 
          Your content to be swiped here
        -->
    </div>
    <left-swipe-action-button>
      <!-- 
        Your action here
      -->
    </left-swipe-action-button>
</left-swipe-action>

Screen example 1
screen1

Screen example 2
screen2

The elements other than left-swipe-action-button will be inserted to shadow DOM as main content. 'left-swipe-action-button' is a button to be fit with a content height. These are aligned as table cells.

CSS for both the main content and buttons in light DOM will be just applied.

Demo

http://tejitak.github.io/left-swipe-action/demo.html

Usage

Simple example

<left-swipe-action shadow>
    <div style="padding: 18px;">
        <div>My first Polymer project</div>
        <div><strong>Swipe me to left</strong></div>
    </div>
    <left-swipe-action-button style="background-color: #E81D62;" onclick="alert('delete')">Delete</left-swipe-action-button>
</left-swipe-action>

Multi actions example with paper elements

<left-swipe-action shadow>
    <div  style="padding: 18px;">
        <p>See how many actions are behind<br><strong>Swipe me to left</strong></p>
    </div>
    <left-swipe-action-button onclick="alert('delete')"><paper-fab icon="delete"></paper-fab></left-swipe-action-button>
    <left-swipe-action-button onclick="alert('star')"><paper-fab icon="star"></paper-fab></left-swipe-action-button>
</left-swipe-action>

This can be worked with Polymer <template repeat> or other MVC library (Angular.js, Vue.js etc.) like the following.

Template repeat example

<template repeat="{{[1,2,3,4,5]}}">
  <left-swipe-action shadow offset="40">
      <div class="list-container">
          <div class="list-thumb"><a href="https://twitter.com/tejitak" target="_blank"><paper-icon-button icon="social:person"></paper-icon-button></a></div>
          <div class="list-content">
              <div class="list-message">Tejitak</div>
              <div class="list-info">Repeated by &lt;template repeat&gt; ...</div>
          </div>
      </div>
      <left-swipe-action-button onclick="alert('delete')"><paper-fab icon="delete"></paper-fab></left-swipe-action-button>
      <left-swipe-action-button onclick="alert('star')"><paper-fab icon="star"></paper-fab></left-swipe-action-button>
      <left-swipe-action-button onclick="alert('schedule')"><paper-fab icon="schedule"></paper-fab></left-swipe-action-button>
  </left-swipe-action>
</template>

Attributes

Name Type Default Description
open boolean false If true, the content will be opened by default
nodrag boolean false If true, drag (touch move) action is disabled and a content is automatically opened by click/touch
offset number 60 Offset pixcel position for opened state
shadow boolean false If true, box shadow is added
disabled boolean false If true, all gestures are disabled

Getting Started

  1. Install with bower
    bower install left-swipe-action --save

  2. Load the web component and the dependencies

<script src="bower_components/webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="bower_components/polymer/polymer.html">
<link rel="import" href="bower_components/left-swipe-action/left-swipe-action.html">
  1. Markup with <left-swipe-action>

  2. Done

Supported Browsers

Same as Polymer

left-swipe-action's People

Contributors

tejitak avatar beeva-miguelcollado avatar kcmr avatar bago2k4 avatar

Watchers

 avatar

Forkers

kcmr ifisidro

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.