@JsType(namespace="xgl") public class Presto extends AnimationFrame
Presto schedules the readings and writings and execute them during the browser's animation frame. Presto prevents layout trashing/reflow.
Presto allows the throttling of high firing rates events.
Modifier and Type | Class and Description |
---|---|
static class |
Presto.State
State is the current state of the Presto scheduler.
|
Modifier and Type | Method and Description |
---|---|
static void |
asSoonAsPossible(Measure measure)
Runs a measure as soon as possible, which means that if the scheduler is in
the
Presto.State.MEASURING state, the measure is run immediately. |
static void |
asSoonAsPossible(Mutation mutation)
Runs a mutation as soon as possible, which means that if the scheduler is
in the
Presto.State.MEASURING or Presto.State.MUTATING state, the
mutation is run in the current cycle. |
static void |
cancel(Measure measure)
Cancels a measure scheduled in the next Presto's cycle.
|
static void |
cancel(Mutation mutation)
Cancels a mutation scheduled in the next Presto's cycle.
|
static void |
cancelMeasure(Measure measure)
Cancels a measure scheduled in the next Presto's cycle.
|
static void |
cancelMutation(Mutation mutation)
Cancels a mutation scheduled in the next Presto's cycle.
|
static boolean |
canRead()
Checks if Presto will allow reading the DOM.
|
static boolean |
canWrite()
Checks if Presto will allow writing in the DOM.
|
static void |
ensureReadable()
Ensures Presto will allow reading the DOM.
|
static void |
ensuresSynchronous()
Ensures Presto is not running its cycle.
|
static void |
ensureWriteable(boolean attached)
Ensures Presto will allow writing in the DOM.
|
static double |
getCycleHighResTimeStamp()
Gets the high-resolution time stamp of the start time of the current cycle.
|
static LayoutLock |
getLock() |
static long |
getRunId()
The run id is incremented at the start of each run of the Presto's cycle.
|
static Presto.State |
getState() |
static double |
highResTimeStamp()
Gets the current high-resolution time stamp.
|
static boolean |
isAsynchronous()
Checks if Presto is running its cycle.
|
static boolean |
isStrictLockMode()
Gets the current Presto's lock mode.
|
static boolean |
isSynchronous()
Checks if Presto is not running its cycle.
|
static void |
measureAsSoonAsPossible(Measure measure)
Runs a measure as soon as possible, which means that if the scheduler is in
the
Presto.State.MEASURING state, the measure is run immediately. |
static void |
mutateAsSoonAsPossible(Mutation mutation)
Runs a mutation as soon as possible, which means that if the scheduler is
in the
Presto.State.MEASURING or Presto.State.MUTATING state, the
mutation is run in the current cycle. |
static void |
now(Immediate immediate)
Execute synchronously the
Immediate object. |
void |
run(double highResTimeStamp)
Runs the Presto cycle.
|
static void |
schedule(Measure measure)
Runs a measure in next Presto's cycle.
|
static void |
schedule(Mutation mutation)
Runs a mutation in the next Presto's cycle.
|
static void |
scheduleMeasure(Measure measure)
Runs a measure in next Presto's cycle.
|
static void |
scheduleMutation(Mutation mutation)
Runs a mutation in the next Presto's cycle.
|
static void |
setStrictLockMode(boolean strictLockMode)
If strictLockMode is false, Presto will allow any interaction with the DOM
outside its cycle.
|
cancel, isScheduled, schedule
public static void now(Immediate immediate)
Immediate
object. Presto allows any
measure and mutation to be performed.immediate
- the action to perform synchronously.@JsIgnore public static void schedule(Measure measure)
measure
- the measure to perform during the next cyclepublic static void scheduleMeasure(Measure measure)
measure
- the measure to perform during the next cycle@JsIgnore public static void schedule(Mutation mutation)
Runs a mutation in the next Presto's cycle.
Note: Mutations are performed after all scheduled measures are executed.
mutation
- the mutation to perform during the next cyclepublic static void scheduleMutation(Mutation mutation)
Runs a mutation in the next Presto's cycle.
Note: Mutations are performed after all scheduled measures are executed.
mutation
- the mutation to perform during the next cyclepublic static void measureAsSoonAsPossible(Measure measure)
Presto.State.MEASURING
state, the measure is run immediately.measure
- the measure to performed as soon as possible@JsIgnore public static void asSoonAsPossible(Measure measure)
Presto.State.MEASURING
state, the measure is run immediately.measure
- the measure to perform as soon as possiblepublic static void mutateAsSoonAsPossible(Mutation mutation)
Presto.State.MEASURING
or Presto.State.MUTATING
state, the
mutation is run in the current cycle. It should never be
used when a measure is needed to perform a mutation. The measure may or may
not be performed when the mutation is performed.mutation
- the mutation to perform as soon as possible@JsIgnore public static void asSoonAsPossible(Mutation mutation)
Presto.State.MEASURING
or Presto.State.MUTATING
state, the
mutation is run in the current cycle. It should never be
used when a measure is needed to perform a mutation. The measure may or may
not be performed when the mutation is performed.mutation
- the mutation to perform as soon as possiblepublic static Presto.State getState()
@JsIgnore public static void cancel(Measure measure)
Cancels a measure scheduled in the next Presto's cycle.
measure
- the measure to cancelpublic static void cancelMeasure(Measure measure)
Cancels a measure scheduled in the next Presto's cycle.
measure
- the measure to cancel@JsIgnore public static void cancel(Mutation mutation)
Cancels a mutation scheduled in the next Presto's cycle.
mutation
- the mutation to cancelpublic static void cancelMutation(Mutation mutation)
Cancels a mutation scheduled in the next Presto's cycle.
mutation
- the mutation to cancelpublic void run(double highResTimeStamp)
Runs the Presto cycle.
Not available to outside access since the class is not instanciable...
run
in class AnimationFrame
AnimationFrame.run(double)
public static LayoutLock getLock()
public static boolean isStrictLockMode()
setStrictLockMode(boolean)
public static void setStrictLockMode(boolean strictLockMode)
If strictLockMode is false, Presto will allow any interaction with the DOM outside its cycle. This disable Presto.
Any measure or mutation added will still be subject to Presto's policy regarding the access to the DOM.
Note: It is best to keep the Strict Lock Mode on.
strictLockMode
- True (default): Presto will control all access to the DOM. False:
Presto will not control access to the DOM not in its cycle.public static boolean canRead()
public static boolean canWrite()
public static void ensureReadable()
IllegalStateException
- if DOM reading is not allowedpublic static void ensureWriteable(boolean attached)
IllegalStateException
- if DOM writing is not allowedpublic static boolean isSynchronous()
public static void ensuresSynchronous()
IllegalStateException
- if Presto cycle is runningpublic static boolean isAsynchronous()
@JsIgnore public static long getRunId()
public static double getCycleHighResTimeStamp()
public static double highResTimeStamp()
Copyright © 2018 Xalys. All rights reserved.