Ticket #7060 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

Improving internal Effects API

Reported by: gnarf Owned by: gnarf
Priority: blocker Milestone: 1.9.0
Component: ui.effects.core Version: 1.8.10
Keywords: Cc:
Blocking: Blocked by:

Description

Currently, the effects functions are being passed an object that looks something like this:

{ options: { pieces: 9 }, mode: 'hide', callback: fn, duration: 200 }

It seems that the options here becomes a little redundant internally, causing a need to reference o.options.pieces instead of just o.pieces

We can pretty easily override this function to create an "Effect Options Object" that would look more like this:

{ effect: 'explode', pieces: 9, mode: 'hide', complete: fn, duration: 200 }

There will be a BC break here - Any custom $.effects[] functions that have been written will need to be updated to replace o.options.* -> o.* and o.callback -> o.complete

It would be possible to add a BC duck punch if necessary, however my quick google search shows no results for "jquery ui effects custom".

I've started cleaning up the API a little here:  https://github.com/gnarf37/jquery-ui/compare/master...effects-api

Let me know if you think the BC punch is needed - I still want to try and clean up some of the effects.js files before I file a pull...

Change History

comment:1 Changed 2 years ago by scott.gonzalez

  • Priority changed from minor to blocker
  • Status changed from new to open

comment:4 Changed 2 years ago by gnarf

Adding another internal effects API issue / idea onto this ticket - might be worthy of its own.

In thinking about how to handle the BC shim for this API change, and other ways we might clean up the internal API - I thought we could move the actual effect implementation functions out of the $.effects[] and into $.effects.effect[] . It gives us a discreet namespace where we are sure that the function is an effect API function. Currently, other functions exist out on $.effects[] that aren't effects, allowing you to get interesting results for $("div").toggle("animateClass") - Letting that namespace hold utility functions, while pushing the actual effects into a new namespace could show some minor improvements.

Also - We could potentially leverage $.effects.$ = jQuery.sub() and extend its fn to serve up the setMode, save, restore, createWrapper, removeWrapper, and a few other helper functions that all take el as a first parameter. Each of the effect functions can then use $.effects.$( this ) and have all the helper functions available in a nice chain.

Got most of these changes in and you can look at the branch here:  https://github.com/gnarf37/jquery-ui/compare/effects-api...effects-sub -- it seems github is mistakenly showing some of the whitespace changes that were in the effects-api branch on the effects-sub branch, but you should get the idea...

comment:5 Changed 2 years ago by gnarf

  • Blocking 7069 added

comment:6 Changed 2 years ago by gnarf

  • Owner set to gnarf
  • Status changed from open to assigned

comment:7 Changed 2 years ago by gnarf

  • Blocking 6022 added

comment:8 Changed 2 years ago by gnarf

  • Blocking 6781 added

comment:9 Changed 2 years ago by scott.gonzalez

  • Status changed from assigned to closed
  • Resolution set to fixed

Merged in gnarf's branch.

comment:10 Changed 2 years ago by gnarf

  • Status changed from closed to reopened
  • Resolution fixed deleted

There is still  https://github.com/jquery/jquery-ui/pull/146 to look at scott - gonna reopen this until you decide there too :)

comment:11 Changed 2 years ago by gnarf

  • Blocking 6022 removed

comment:12 Changed 2 years ago by gnarf

  • Status changed from reopened to closed
  • Resolution set to fixed

Reclosing at scotts request... see http://bugs.jqueryui.com/ticket/7103 for the other parts...

comment:13 Changed 2 years ago by gnarf

  • Blocking 6781 removed

comment:14 Changed 6 months ago by mikesherov

  • Blocking 7069 removed
Note: See TracTickets for help on using tickets.