Skip to content

leanModal with zepto instead of jQuery #43

@sheffieldnikki

Description

@sheffieldnikki

To get leanModal working as a zepto plugin, a few small changes are needed:

    // Zepto doesn't have $.fn.extend()
    //$.fn.extend({ 
    $.fn.leanModal = function(options) {

and

                // Zepto doesn't have .outerWidth(), and modal_height not used!
                //var modal_height = $(modal_id).outerHeight();
                //var modal_width = $(modal_id).outerWidth();
                var el = $(modal_id);
                el.css({'display': 'block', 'opacity': 0});
                var modal_width = (typeof el.outerWidth != 'function') ? el.width() : el.outerWidth();

.width() returns 0 if the modal is display:none, so 'display' it first, but transparent.

})(window.jQuery || window.Zepto);

You will need the core zepto.js library, as well as the zepto.fx.js and zepto.fx_methods.js plugins, for the fadeIn/Out animation to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions