Code Monkey home page Code Monkey logo

flippy's Introduction

Flippy jQuery Plugin

Demo

view the Demo

Features

  • Use CSS3 transform option when the browser supports it
  • Animate multiple element simultaneously
  • Revert the last flip animation with $('#myElement').flippyReverse();
  • Multiple callback on start, half way, during the animation and when finished
  • Flip content without breaking event bindings

Options

  • color_target : The targeted background color. (ex.: ‘aliceblue’, ‘#f0f8ff’ or rgba(33,133,197,.3) | default: ‘white’)
  • content (deprecated please now use verso option) : The content to show after the flip effect, HTML or jQuery objects
  • recto : The content to show after a revert() action (default : the original content)
  • verso : The content to show after the flip effect
  • direction : The direction of the flip effect (‘RIGHT’, ‘LEFT’, ‘BOTTOM’, ‘TOP’ | default : ‘LEFT’)
  • duration : How long the flip effect is during in ms (default : 300)
  • depth : You can adjust the perspective effect (default : 0.12)
  • light : You can adjust light and shadow intensity (default : 60)
  • noCSS : You can force Flippy to NOT use CSS3 properties even if the browser support it (default : false)
  • noRemove: You can prevent Flippy from injecting and removing dom elements, instead use css to show/hide (default : false)
  • backhtml: Use to inject content into the flipbox even when noRemove is true
  • onStart : The function triggered before the animation start
  • onMidway : The function triggered at half animation
  • onAnimation : The function triggered each time the Flippy is refreshed
  • onFinish : The function triggered after the animation finish
  • onReverseStart : The function triggered before the animation start
  • onReverseMidway : The function triggered at half animation
  • onReverseAnimation : The function triggered each time the Flippy is refreshed
  • onReverseFinish : The function triggered after the animation finish

Markup

<div class="flipbox-container">

    <div id="myFlippyBox">
        <span>Hello !</span>
    </div>

</div>

Example

$("#myFlippyBox").flippy({
	verso:"Hi !",
	direction:"TOP",
	duration:"750",
	onStart:function(){
		alert("Let's flip");
	},
	onFinish:function(){
		alert("ok, it's flipped :)");
	}
});

// If you want to revert the last animation
$("#myFlippyBox").flippyReverse();

Example noRemove

Setting noRemove to true prevents Flippy from injecting elements into the DOM as well as using remove. This is useful for elements with event bindings that can be lost when removed from the DOM.

When using noRemove, verso and recto have different purposes. Instead of holding the content to inject into the DOM, verso and recto represent a selector of the content to be flipped to and the currently displayed content.

  • noRemove : Set to true to use noRemove instead of normal inject/remove Flippy
  • verso : Selector of the content to flip to
  • recto : Selector of the currently displayed content (used for flippyReverse)
  • backhtml : Use to inject content into the flipbox even when noRemove is true

If the element that verso points to exists already, backhtml does not re-inject content.

$("#myFlippyBox").flippy({
  verso:"#backSide",
  recto:"#frontSide",
  backhtml: "<div id='backSide'>Hello</div>"
  noRemove: true,
  direction:"TOP",
  duration:"750",
  onStart:function(){
    alert("Let's flip");
  },
  onFinish:function(){
    alert("ok, it's flipped :)");
  }
});

// If you want to revert the last animation
$("#myFlippyBox").flippyReverse();

Licence

Released under the MIT license

flippy's People

Contributors

dannywils avatar dartandrevinsky avatar jmmerino avatar pjehan avatar yemm avatar zsher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flippy's Issues

Function toDec

Error:
Uncaught ReferenceError: g is not defined
jquery.flippy.js:417

If I replace with this it and work for me:

function toDec(hex){
    return parseInt(hex, 16);
}

strange effect with depth?

No matter on what value I set depth to, it seems to do nothing on Chrome, and on FF/IE it tries to come out of the screen and slap the user xD

I just implemented it on http://elggtest.pattyland.de/ , click on "Registrieren" to trigger the flip, and on "Login" to trigger it back.

Or am I'm doing something wrong?

EDIT: On the demosite the plugin seems to set the perspective on the parent of the flippy element, unfortunately not on my site :(

flip Refresh problem on android phonegap build

I try to use flippy plugin for a memory game with flipping tiles on click.

All works fine for all browsers (firefox, chrome ...), even on android devices, and for IOS build with phonegap, even for tizen builds, but there is a strange behavior with android phonegap build :

the first clicked tile flips perfectly, but for all the next tiles i click on, the recto side remains visible under the flip effect, and under the reverse flip effect too.

If i click again on the first tile, it allways works perfectly.

Any idea to help me ?

how can i use listing

As i tried UL class flippy and tried its Li to rotate but got no success while UL is rotating will all li elements. any solution?

Internet Explorer 10 support

I see you have

_isIE = (navigator.appName == "Microsoft Internet Explorer");
_isIE9 = (navigator.appVersion == "9.0");

when I visit the demo with a IE10 the flip does not work at all (the item just disappears)

from what I can see you treat IE9 different from older IEs, maybe this issue can be resolved by just changing _isIE9 to _isIE9orHigher for it is save to assume that IE10 has equal or better support for features existing in IE9

Changing rotation point

Hi,
is it possible to change the rotation point. I would use it for a common page flip and need it to rotate the div around the side.

thanks,
Elio

background_target...?

i am calling a login form/a div, from index.html to show in flippy trought this:

$("#btn-login").on("click",function(e){
$(".flipbox").flippy({
color_target: "#131516",
direction: "bottom",
duration: "450",
content: $("#login").html(),
});
e.preventDefault();
});

now i want to change the "color_target" on line 3 to a image. its going to be the background and have the same css as the flippy box it self, because i made round corners on flippy box.

is it possible?

Verso content of another DIV

Actually I created a div with display: none, and in the setup script I wrote:

verso: $('#my_hidden_div').html(),

there are other ways to do that thing?

flippyReverse() reverting incorrect flipbox.

I don't think this is a flippy issue, but I figured this might be the best place to ask.
I have code that is executed on a flipbox container after a button on it is clicked.
The onMidway code attaches the the listeners to the buttons on the back of the card, both which flip the card back to the front side. The timeout is there because it won't attach if it isn't (I'm guessing it isn't in the DOM yet).

The code works fine when only one card is flipped at a time, but, for example, if:

  1. card 1 button is clicked to flip it to the back side
  2. card 2 button is clicked to flip it to the back side
  3. card 1 button is clicked to revert it to the front, but instead card 2 is reverted.

So, no matter which card is clicked on, what ever card was flipped to the back most recently will be the one that is reverted. I can revert any one I want by calling $('#whatever-id').flippyReverse() from the console, so I know that the reviewNumber is incorrect in the function below, but I can't figure out why. reviewNumber must always equal whatever the most recently clicked review was, but I can't figure out how to get around it. I'm new to JS, jQuery, and HTML, so I'm pretty sure there's a way to do this that I just can't see yet.

    approveReview: function(event){
        reviewNumber = event.target.id.split('-')[2];
        var submitted = true;
        var initialHeight = $('#read-review-flipbox-' + reviewNumber).height();

        $('#read-review-flipbox-' + reviewNumber).flippy({
            duration: globals.flippyDuration,
            verso:  '<div id="dashboard-flipped-' + reviewNumber +'" style="padding-top:35%;">'+
                        '<h2 class="no-v-margin" style="text-align:center;">Are you sure you want to approve this review?</h2>'+
                        '<div class="ui-grid-a">'+
                            '<div class="ui-block-a">'+
                                '<button id="dashboard-deny-approve-'+ reviewNumber +'" data-theme="e">Cancel</button>'+
                            '</div>'+
                            '<div class="ui-block-b">'+
                                '<button id="dashboard-confirm-approve-'+ reviewNumber +'" data-theme="b">Approve review</button>'+
                            '</div>'+
                        '</div>'+
                    '</div>',

            onMidway: function(){
                $('#read-review-flipbox-' + reviewNumber).height(initialHeight);
                setTimeout(function(){
                    $('#dashboard-flipped-' + reviewNumber).trigger('create');
                    $('#dashboard-confirm-approve-' + reviewNumber).on('click', function(){
                        $('#read-review-flipbox-' + reviewNumber).flippyReverse();
                        // TODO: add DB CODE HERE
                    });
                    $('#dashboard-deny-approve-' + reviewNumber).on('click', function(){
                        $('#read-review-flipbox-' + reviewNumber).flippyReverse();
                        submitted = false;
                    });
                }, 10);
            },

            onReverseMidway: function(){
                setTimeout(function(){
                    if(submitted){
                        $('#approval-buttons-' + reviewNumber).html('<h2 style="text-align:center;">Review approved.</h2>');
                    }
                    else{
                        $('#disapprove-button-' + reviewNumber).on('click', dashboard.disapproveReview);
                        $('#approve-button-' + reviewNumber).on('click', dashboard.approveReview);
                    }
                }, 10);
            }
        });
    },

Thanks in advance.

flippyReverse with "override"

Hi,

I just faced a very specific problem, not a blocking one, but maybe it could be useful.

I use Flippy to display a form.
This form has a "Cancel" button, configured with flippyReverse.

  • First, this button was inside a display:none block. Problem: flippyReverse had no effect.
  • Okay no prob, I put it outside this block, and add a "on/off" class, to play with removeClass and addClass.

It works well... But because flippyReverse is like a "reverse replay" function (that's right ?), it also play again my original onFinish option. Result: it removes the "off" class, then add the "on" one again :)

Would it be possible to use options in flippyReverse, in order to override the options defined in the "replayed" effect ? I tried, but it seems not working.

Of course now I finally use a classic "flippy" instead of flippyReverse, but why write 10 lines when you could write 5 ;-)

Thanks.

Hover flip effect

Hi I tried to implement your flippy plugin but I have some difficulty to make it works.

I want to flip my thumbnail with a mouse over. And to flip again on mouveleave.

Here an example of what I tried to do : http://fiddle.jshell.net/52mG7/2/

Loïc

rgba is not working?

Hi when I put color_target: "rgba(255,255,255,0.6)" flippy is flipping only 50% and it dissapears :( after that when i am clicking flippy to flip nothing is happening until refreshing page

flippy with .hover() / .mouseenter()..

Great plugin!
But is there a reason why there is a consecutive mouseenter/mouseover event triggered while mousover action? Why not only once?
retards
manu

responsive image

Hi
i am using flippy with bootstrap. and i want the image thats inside my flippys to be responsive like the box it self. did like this:

$("#btn-left").on("click",function(e){
    $(".flipbox").flippy({
        color_target: "red",
        direction: "left",
        duration: "450",
        verso: "<div class='imgs'><img src='images/pages/frontpage.png' alt='' /></div>",
     });
     e.preventDefault();
});

box respond by default, but not the image.

thanx!!!

Strange Flipping dimensions on IE10 engine

Hey, i've been trying to implement your plugin, and it seems to work on all other browsers, but on IE10 I get some weird behaviour, that you're demo is not doing.

Can you check it out for me and maybe spot what I missed?

http://next.online-beheer.nl/

I found out that the behaviour changes a little when I put a container around the div I am trying to flip, but I can't seem to isolate the reason.

Unable to animate two flippys at once

I have js code that looks like this:

$("a").flippy(...);
$("b").flippy(...);

This does not work. The second one causes an error (as shown in the browser's console). I believe it's not possible to do two at once until the first is done its animation.

Multiple instances of flippy images disappearing

I've been scratching my head for some time now and any help would really be greatly appreciated.

I have multiple instances of a flippy elements but for some reason when I have them going each at their own intervals the recto image disappears on some and on others the verso image disappears they reappear each at their own time but this is causing some bad layout problems.

Here is my function:

function flipper() {
// Flipping Randomizer
var rand = Math.round(Math.random() * (10000 - 500)) + 900; // Randomizer setting to init flipping
var topImg = $('.flipper img + img');
var btmImg = $('.flipper img');
var win = $(window);

$('.flipper').each(function(i) {
    var thisFlippy = $(this);

    thisFlippy.flippy({
        verso: topImg,
        direction: 'LEFT',
        duration: '850',
        depth: 25,
        recto: btmImg,
        onFinish: function() {

            setTimeout(function() {
                if ( !blnFlippyPaused ) {
                    thisFlippy.flippyReverse();
                }
            }, rand);

        },
        onReverseFinish: function() {
            setTimeout(function() {
                if ( !blnFlippyPaused ) {
                    thisFlippy.flippyReverse();
                }
            }, rand);
        }
    });
});

};

<div class="col-xs-12 col-md-6 flipbox-container item" role="single-column">
        <a class="music-player" href="#">
            <figure role="music-container" class="flipper">
                <img src="'+ base_url +'/assets/img/'+ language +'/pre-seeded/tiles/summer_playlist.jpg" alt="" class="img-responsive">
                <img src="'+ base_url +'/assets/img/'+ language +'/pre-seeded/tiles/summer_playlist_flipped.jpg" alt="" class="img-responsive">
            </figure>
        </a>
    </div>

<div class="col-xs-12 col-md-6 flipbox-container item" role="single-column">
        <a class="music-player" href="#">
            <figure role="music-container" class="flipper">
                <img src="'+ base_url +'/assets/img/'+ language +'/pre-seeded/tiles/summer_playlist.jpg" alt="" class="img-responsive">
                <img src="'+ base_url +'/assets/img/'+ language +'/pre-seeded/tiles/summer_playlist_flipped.jpg" alt="" class="img-responsive">
            </figure>
        </a>
    </div>

Do I need to apply height to the container?

direction option case sensitive

the direction option, i.e. "TOP" appears to be case sensitive and is causing unexpected results if "top" (bottom, etc.) is used instead.

It might be worth adding a toLowerCase() to the option to prevent this unexpected behavior from occurring as it has the potential to confuse new users.

Very strange behavior while onclick

When i have it do the flip on load, it flips perfect. However, the second I try doing it onclick things get weird.

Check it out here:
new.almostfamous.com/test.html

Any idea what's up?

[enhancement] Add missing bower.json.

Hey, maintainer(s) of lepixel/flippy!

We at VersionEye are working hard to keep up the quality of the bower's registry.

We just finished our initial analysis of the quality of the Bower.io registry:

7530 - registered packages, 224 of them doesnt exists anymore;

We analysed 7306 existing packages and 1070 of them don't have bower.json on the master branch ( that's where a Bower client pulls a data ).

Sadly, your library lepixel/flippy is one of them.

Can you spare 15 minutes to help us to make Bower better?

Just add a new file bower.json and change attributes.

{
  "name": "lepixel/flippy",
  "version": "1.0.0",
  "main": "path/to/main.css",
  "description": "please add it",
  "license": "Eclipse",
  "ignore": [
    ".jshintrc",
    "**/*.txt"
  ],
  "dependencies": {
    "<dependency_name>": "<semantic_version>",
    "<dependency_name>": "<Local_folder>",
    "<dependency_name>": "<package>"
  },
  "devDependencies": {
    "<test-framework-name>": "<version>"
  }
}

Read more about bower.json on the official spefication and nodejs semver library has great examples of proper versioning.

NB! Please validate your bower.json with jsonlint before commiting your updates.

Thank you!

Timo,
twitter: @versioneye
email: [email protected]
VersionEye - no more legacy software!

adding recommend markup and css to readme page

It would be very helpful to have some recommended markup and css added to the readme page in order to help new users get started as quickly as possible without having to examine the source code in the demo page.

btw, thanks for this awesome plugin!

Flipping Display Issue

The latest version of Chrome (36.0.1985.125) has a display issue whilst flipping over. It seems to use the screen size to flip rather than the div size and so the rotating looks very strange.

It also appears in Firefox 30.0 and Internet Explorer 11.

This occurs in my own code and also your demo site at http://blog.guilhemmarty.com/flippy/.

They did used to work fine, but it looks like all the browsers have implemented some changes which has caused the problem.

Full turn

Any chance you will add a full spin option? And when I say full spin, I mean a 360 spin instead of a 180 spin. Thx

Take out the background color.

Hey,
I think you've made a great plugin, I don't understand why you have a background color property. I just wanted to flip a png image and swap it with another one. Why are you forcing there to be a background color? The flip still works with transparency. I ended up taking out several lines of code to make it work... The background color should be in the CSS, not taken charge with your plugin. Your plugin should only flip stuff.

Having said that, thanks for the plugin. It works and i'm happy with the results :)

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.