Expansion subsequent minor update
What’s new 🔥
- Animation features 👁️
const balloonContainer = document.getElementById("balloon-container"); function random(num) { return Math.floor(Math.random() * num); } function getRandomStyles() { var r = random(255); var g = random(255); var b = random(255); var mt = random(200); var ml = random(50); var dur = random(5) + 5; return ` background-color: rgba(${r},${g},${b},0.7); color: rgba(${r},${g},${b},0.7); box-shadow: inset -7px -3px 10px rgba(${r - 10},${g - 10},${b - 10},0.7); margin: ${mt}px 0 0 ${ml}px; animation: float ${dur}s ease-in infinite `; } function createBalloons(num) { for (var i = num; i > 0; i--) { var balloon = document.createElement("div"); balloon.className = "balloon"; balloon.style.cssText = getRandomStyles(); balloonContainer.append(balloon); } } function removeBalloons() { balloonContainer.style.opacity = 0; setTimeout(() => { balloonContainer.remove() }, 500) } createBalloons(10); setTimeout(removeBalloons, 15000); return '';
note
This update does not affect the core of WLJS Notebook and will be installed automatically for certain modules.
Animate
The missing function from Mathematica is back!
tip
We still do recommend to prefer AnimatePlot
or manual dynamics when it comes to plotting, however for arbitary expressions Animate
is the way to go
restart = InputButton["Replay"] Animate[ Row[{Sin[x], "==", Series[Sin[x], {x,0,n}], Invisible[1/2]}], {n, 1, 10, 1}, AnimationRate->3, "TriggerEvent"->restart ]
(*VB[*)(EventObject[<|"Id" -> "a76dc175-bdad-4d68-8d65-4515676cbd97", "Initial" -> False, "View" -> "86d9172c-c44d-4a6f-b814-9311f8aca8f3"|>])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKW5ilWBqaGyXrJpuYpOiaJJql6SZZGJroWhobGqZZJCYnWqQZAwCBIBWs"*)(*]VB*)
(*VB[*)(FrontEndRef["d41fbaa8-12f3-4382-8f6d-c065a7ba14b5"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKp5gYpiUlJlroGhqlGeuaGFsY6VqkmaXoJhuYmSaaJyUamiSZAgCJaRXI"*)(*]VB*)
More control over ManipulatePlot
We provide a possibillity to alter update method for Animate
, Manipulate
and ManipulatePlot
. This is the great way to perform side effects
Module[{label, pos}, ManipulatePlot[x w, {x,0,1}, {w,0,2}, Epilog->Text[Style[label // Offload, FontSize->14], pos // Offload], "UpdateFunction" -> Function[input, label = StringTemplate["w = ``"][SetPrecision[input,2]]; pos = {0.5, input 0.5 + 0.2}; True ] ] ]
(*GB[*){{(*VB[*)(Graphics[{AbsoluteThickness[2], RGBColor[0.368417, 0.506779, 0.709798], Line[Offload[CoffeeLiqueur`Extensions`Manipulate`Internal`pts$4252473]]}, ImageSize -> {400, 300}, PlotRange -> Automatic, Axes -> True, TransitionType -> "Linear", TransitionDuration -> 50, Epilog -> Text[Style[Offload[label$4252470], FontSize -> 14], Offload[pos$4252470]], Prolog -> {}, AxesLabel -> {}, "TrackedExpression" -> Null, PlotRange -> {{-0.050000000000000044, 1.05}, {-0.050000000000000044, 1.05}}])(*,*)(*"1:eJyFUrtOQkEQveI7RhP8AxNKC0UMdgQRkYhKgA9ggbm4Ydm97iO5WFtYGmNQO1v9AFtLG61tbTSx8xPc8UIID3GL2Zmds7Nnz8xKRRTcCcdx1JQ1e4LV3AWM5qzJSOId06pyJ7v5HFU6QIetSVaUYEZDyYIaHJSiIXsaoPF+IbOdEkxI6bUvPyJXbwm53v66Po+/J+Tz2c3+w+Nnovd0jnIIollrjlyXCVJTW9ZPCdcFyNETA0aW074GrqjgqnxAOPUMIxrKWa5BcsLKnlaRWHQzGotvuKFu7YJhoOatk22SOhTpKfRy+CV6YR+mq9aMuJNnQhcIrwdR0mjRJJpWB5DoJH2rATolaWAgv/R7TCxzbbmXWh4UZzq/JnIAu9yH3TGS4E6jzhA/LJH2KBP1XqIEvg6iaWuKusVG6LpofUYqwDpirQ0UxvbtCq5RK4rch0vgmHhC/VEAmeWlQGZO3/QMC4yy5ZDLOGQxHIhSbUAt7XsSp83OAKYPDWPj+tbf6/5I3t3iun+Sry+4vhP/5X8AQ73U9Q=="*)(*]VB*)(*|*),(*|*)(*VB[*)(EventObject[<|"Id" -> "79d02d24-5891-42d3-9af0-5d9dca4f84e2", "Initial" -> {1.}, "View" -> "9434471c-bfa0-4432-82e7-f398af67bef6"|>])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKW5oYm5iYGybrJqUlGuiamBgb6VoYpZrrphlbWiSmmZknpaaZAQB5TxWD"*)(*]VB*)}}(*]GB*)
If UpdateFunction
returns False
it prevents the default update action. For example
Module[{r}, Manipulate[Graphics[Disk[{0,0}, r//Offload], ImageSize->200], {{radius, 1, "Radius"}, 0,1, 0.3}, "UpdateFunction" -> Function[value, r = value; False ] ] ]
(*GB[*){{(*VB[*)(EventObject[<|"Id" -> "e142634e-b787-4e69-ae16-493bef78739d", "Initial" -> {0.8999999999999999}, "View" -> "484b219f-36a2-444c-840f-0ea656aea910"|>])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKm1iYJBkZWqbpGpslGumamJgk61qYGKTpGqQmmpmaJaYmWhoaAAB4iRU8"*)(*]VB*)}(*||*),(*||*){(*VB[*)(FrontEndRef["e742dafc-6712-4b9f-b13a-11afb4762dc3"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKp5qbGKUkpiXrmpkbGumaJFmm6SYZGifqGhompiWZmJsZpSQbAwCL1xX3"*)(*]VB*)}}(*]GB*)
Ballon animation by Jemima (codepen)