Porting from MMA
In most cases, if you have Manipulate or Animate expressions in your Mathematica code, no changes are required to run them in the WLJS Notebook environment. The only concern is performance:
Manipulate
andAnimate
are very general and perform full reevaluation of your manipulated expression.- Wolfram Mathematica attempts to optimize reevaluation internally, while WLJS Notebook does not have this feature.
Manipulate
,Animate
, andRefresh
are considered anti-patterns for displaying rapidly changing data points and will work even slower compared to Mathematica.
How to Optimize
Dynamic Plots
If you want to manipulate the parameters of a given function and plot the curves, consider using ManipulatePlot or related functions.
Low-level dynamics (see Dynamics) is also a viable option.
If changes are not possible
As alternative way we can suggest to wrap Manipulate
with MMAView, it will use native Mathematica's renderer (rasterized graphics) and create an interactive widget. However, this makes it impossible to export to Dynamic HTML.
Animations
To animate curves or other graphical primitives, consider providing a custom "UpdateFunction"
for Animate, which will only change the symbols your graphics primitives depend on.
See the step-by-step guide in the same section: Porting: Animation.
For static pre-calculated animation try: AnimatePlot.
For more complex animations, consider using: AnimationFrameListener, the entire Animation Framework section, and the Animation subsection in the Advanced
section.
If changes are not possible
MMAView
As alternative way we can suggest to wrap Animate
with MMAView, it will use native Mathematica's renderer and return rasterized image. However, this makes it impossible to export to Dynamic HTML.
Rasterize all frames
Map Rasterize over all "frames" of your animation and then apply ListAnimate or convert to a video.
DynamicModule
This concept is not supported in WLJS Notebook and likely never will be. The closest alternative is using low-level dynamics with GUI blocks (see Mouse and Keyboard), Offload, and a standard Module
expression.