From c248065321efb49dc095e156cde8fa05c9e9d2df Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Tue, 1 Mar 2016 23:36:22 +0000
Subject: animate (28feb16)

git-svn-id: svn://tug.org/texlive/trunk@39907 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/latex/animate/animate.sty | 87 ++++++++++++++-----------
 1 file changed, 50 insertions(+), 37 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/animate/animate.sty')

diff --git a/Master/texmf-dist/tex/latex/animate/animate.sty b/Master/texmf-dist/tex/latex/animate/animate.sty
index 45f5aa79259..ab5eaecabdd 100644
--- a/Master/texmf-dist/tex/latex/animate/animate.sty
+++ b/Master/texmf-dist/tex/latex/animate/animate.sty
@@ -13,7 +13,7 @@
 
 \NeedsTeXFormat{LaTeX2e}
 
-\def\@anim@version{2016/02/15}
+\def\@anim@version{2016/02/28}
 \ProvidesPackage{animate}
 [\@anim@version\space PDF animations from files and inline graphics]
 
@@ -56,12 +56,12 @@
   \DeclareOption{dvipdfmx}{%
     \setboolean{@anim@dvipdfmx}{true}
     \setboolean{@anim@dvips}{false}
-    \PassOptionsToPackage{dvipdfmx}{ocgbase}
+    \PassOptionsToPackage{dvipdfmx}{pdfbase}
   }
   \DeclareOption{xetex}{%
     \setboolean{@anim@dvipdfmx}{true}
     \setboolean{@anim@dvips}{false}
-    \PassOptionsToPackage{xetex}{ocgbase}
+    \PassOptionsToPackage{xetex}{pdfbase}
   }
 \fi
 \newboolean{@anim@xetex}
@@ -490,9 +490,10 @@
     \def\@anim@refobj#1{#1}
 
     \def\@anim@xform#1#2#3{%#1 add. pgf resources ? 1:0, #2 not used, #3 boxnum
-      \special{pdf:bxobj @anm@obj\the\@anim@objnum\space width \strip@pt\wd#3pt
-        height \strip@pt\ht#3pt depth \strip@pt\dp#3pt}%
-      \rlap{\vbox to \z@{\vss\box#3}}%
+      \special{pdf:bxobj @anm@obj\the\@anim@objnum\space
+        width \the\wd#3
+        height \the\ht#3 depth \the\dp#3}%
+      \begin{picture}(0,0)\put(0,0){\box#3}\end{picture}%
       \ifx1#1%
         \ifthenelse{\boolean{@anim@pgfloaded}}{%
           \def\@anim@resources{}%
@@ -637,7 +638,7 @@
         }?pdfmark
         \fi%
       }%
-      \rlap{\vbox to \z@{\vss\box#3}}%
+      \begin{picture}(0,0)\put(0,0){\box#3}\end{picture}%
       \special{ps:
         mark /EP pdfmark
         grestore%
@@ -1878,6 +1879,7 @@
 %frame OCGs
 \def\@anim@animwidget#1{%
   \@anim@pojscript{#1}%
+  \@anim@pcjscript{#1}%
   \@anim@otherjscript{#1}%
   \def\@anim@annotflag{}%
   \ifnum\@anim@poster>\@anim@maxframe\relax%
@@ -1934,6 +1936,9 @@
     /Contents (animation by animate[\@anim@version])%
     /AA <<%
       /PV <</S/JavaScript/JS \@anim@pojscriptobj>>% PageVisible
+      /PO <</S/JavaScript/JS \@anim@pojscriptobj>>% PageOpen
+      /PI <</S/JavaScript/JS \@anim@pcjscriptobj>>% PageInvisible
+      /PC <</S/JavaScript/JS \@anim@pcjscriptobj>>% PageClose
       \@anim@otherjscriptkey%
     >>%
     /AP <</N \@anim@apmk>>%
@@ -2164,14 +2169,16 @@
 
 %starts new frame
 \def\@anim@beginframe{%
-  \begin{lrbox}{\@anim@box}% store graphics in a box
+  \begingroup%
+  \lrbox{\@anim@box}% store graphics in a box
   \@anim@begin%
 }
 
 %terminates current frame
 \def\@anim@endframe#1#2{%
   \@anim@end%
-  \end{lrbox}%
+  \endlrbox%
+  \endgroup%
   \ifnum\@anim@skipfram=\z@\relax%
     \ifnum#2=\z@\relax%
       \ifdim\wd\@anim@box=\z@%
@@ -3268,7 +3275,7 @@
 \expandafter\@anim@setpkgkeys\@anim@pkgopts
 
 %JavaScript objects
-%animation widget's PageOpen event
+%animation widget's PageOpen/PageVisible event
 \def\@anim@pojscript#1{%
   \@anim@streamobj{}{\@anim@@pojscript{#1}}%
   \xdef\@anim@pojscriptobj{\@anim@lastobj}%
@@ -3290,7 +3297,7 @@
         app.alert('Icon-based'+spc+'animation'+spc+'is'+spc+'not'+spc+%
           'supported'+spc+'by'+spc+'this'+spc+'Reader.'+spc+'Try'+spc+%
           'one'+spc+'of'+spc+'"method=widget"'+spc+'or'+spc+%
-          '"method=useocg"'+spc+'options.');%
+          '"method=ocg"'+spc+'options.');%
       }%
       a#1.wid=this.getField('anm#1');%reference to interactive widget
       for(i=0;i<=\@anim@maxframe;i++){%
@@ -3671,35 +3678,41 @@
   \fi%
 }
 
+%animation widget's PageClose and PageInvisible events
+\def\@anim@pcjscript#1{%
+  \@anim@streamobj{}{\@anim@@pcjscript{#1}}%
+  \xdef\@anim@pcjscriptobj{\@anim@lastobj}%
+}
+\def\@anim@@pcjscript#1{% #1: @anim@num
+  \if@anim@step%
+    \if@anim@palindrome a#1.playsRight=true;\fi%
+  \else
+    if(a#1.playing){
+      \if@anim@autopause
+        a#1.pause();%
+      \else
+        a#1.pause(true);% stop
+      \fi%
+    }%
+    \if@anim@morejs if(!a#1.isPaused)a#1.playsRight=true;\fi%
+  \fi
+  %re-display poster frame
+  if(!a#1.isPaused){% i.e. if stopped
+    \ifnum\@anim@poster=\@anim@mtwo %poster=none
+      var ret=app.setTimeOut('a#1.seekFrame(-2)',1);%
+    \fi%
+    \ifnum\@anim@poster>\@anim@mone %poster=<num>|first
+      var ret=app.setTimeOut('a#1.seekFrame(\@anim@poster)',1);%
+    \fi%
+    \ifnum\@anim@poster=\@anim@mone %poster=last
+      var ret=app.setTimeOut('a#1.seekFrame(\@anim@maxframe)',1);%
+    \fi%
+  }%
+}
+
 %other trigger events in the anim widget's AA dictionary
 \def\@anim@otherjscript#1{%
   \xdef\@anim@otherjscriptkey{%
-    /PC <</S/JavaScript/JS (% PageClose
-      \if@anim@step%
-        \if@anim@palindrome a#1.playsRight=true;\fi%
-      \else
-        if(a#1.playing){
-          \if@anim@autopause
-            a#1.pause();%
-          \else
-            a#1.pause(true);% stop
-          \fi%
-        }%
-        \if@anim@morejs if(!a#1.isPaused)a#1.playsRight=true;\fi%
-      \fi
-      %re-display poster frame
-      if(!a#1.isPaused){% i.e. if stopped
-        \ifnum\@anim@poster=\@anim@mtwo %poster=none
-          var ret=app.setTimeOut('a#1.seekFrame(-2)',1);%
-        \fi%
-        \ifnum\@anim@poster>\@anim@mone %poster=<num>|first
-          var ret=app.setTimeOut('a#1.seekFrame(\@anim@poster)',1);%
-        \fi%
-        \ifnum\@anim@poster=\@anim@mone %poster=last
-          var ret=app.setTimeOut('a#1.seekFrame(\@anim@maxframe)',1);%
-        \fi%
-      }%
-    )>>%
     /D <</S/JavaScript/JS (%
       app.focusRect=false;% disable focus rectangle
       \if@anim@step\else % pause on MouseDown
-- 
cgit v1.2.3

