Safari JS reference

90
Safari DOM Additions Reference User Experience 2010-05-19

Transcript of Safari JS reference

Page 1: Safari JS reference

Safari DOM Additions ReferenceUser Experience

2010-05-19

Page 2: Safari JS reference

Apple Inc.© 2010 Apple Inc.All rights reserved.

No part of this publication may be reproduced,stored in a retrieval system, or transmitted, inany form or by any means, mechanical,electronic, photocopying, recording, orotherwise, without prior written permission ofApple Inc., with the following exceptions: Anyperson is hereby authorized to storedocumentation on a single computer forpersonal use only and to print copies ofdocumentation for personal use provided thatthe documentation contains Apple’s copyrightnotice.

The Apple logo is a trademark of Apple Inc.

Use of the “keyboard” Apple logo(Option-Shift-K) for commercial purposeswithout the prior written consent of Apple mayconstitute trademark infringement and unfaircompetition in violation of federal and statelaws.

No licenses, express or implied, are grantedwith respect to any of the technology describedin this document. Apple retains all intellectualproperty rights associated with the technologydescribed in this document. This document isintended to assist application developers todevelop applications only for Apple-labeledcomputers.

Every effort has been made to ensure that theinformation in this document is accurate. Appleis not responsible for typographical errors.

Apple Inc.1 Infinite LoopCupertino, CA 95014408-996-1010

Apple, the Apple logo, iPhone, QuickTime, andSafari are trademarks of Apple Inc., registeredin the United States and other countries.

Java is a registered trademark of Oracle and/orits affiliates

IOS is a trademark or registered trademark ofCisco in the U.S. and other countries and is usedunder license.

SPEC is a registered trademark of the StandardPerformance Evaluation Corporation (SPEC).

Simultaneously published in the United Statesand Canada.

Even though Apple has reviewed this document,APPLE MAKES NO WARRANTY OR REPRESENTATION,

EITHER EXPRESS OR IMPLIED, WITH RESPECT TOTHIS DOCUMENT, ITS QUALITY, ACCURACY,MERCHANTABILITY, OR FITNESS FOR A PARTICULARPURPOSE. AS A RESULT, THIS DOCUMENT ISPROVIDED “AS IS,” AND YOU, THE READER, AREASSUMING THE ENTIRE RISK AS TO ITS QUALITYAND ACCURACY.

IN NO EVENT WILL APPLE BE LIABLE FOR DIRECT,INDIRECT, SPECIAL, INCIDENTAL, ORCONSEQUENTIAL DAMAGES RESULTING FROM ANYDEFECT OR INACCURACY IN THIS DOCUMENT, evenif advised of the possibility of such damages.

THE WARRANTY AND REMEDIES SET FORTH ABOVEARE EXCLUSIVE AND IN LIEU OF ALL OTHERS, ORALOR WRITTEN, EXPRESS OR IMPLIED. No Appledealer, agent, or employee is authorized to makeany modification, extension, or addition to thiswarranty.

Some states do not allow the exclusion or limitationof implied warranties or liability for incidental orconsequential damages, so the above limitation orexclusion may not apply to you. This warranty givesyou specific legal rights, and you may also haveother rights which vary from state to state.

Page 3: Safari JS reference

Contents

Introduction Safari DOM Additions Reference 9

See Also 9

Part I Classes 11

Chapter 1 CSSRule Additions Reference 13

Overview 13Constants 13

Chapter 2 Document Additions Reference 15

Overview 15Tasks 15Methods 15

Chapter 3 DOMApplicationCache Class Reference 17

Overview 17Tasks 17Properties 18Methods 20Constants 20

Chapter 4 DOMWindow Additions Reference 23

Overview 23Tasks 23Properties 23Methods 24

Chapter 5 GestureEvent Class Reference 27

Overview 27

Chapter 6 HTMLAudioElement Class Reference 29

Overview 29

32010-05-19 | © 2010 Apple Inc. All Rights Reserved.

Page 4: Safari JS reference

Chapter 7 HTMLMediaElement Class Reference 31

Overview 31Tasks 32Properties 34Methods 39Constants 40

Chapter 8 HTMLVideoElement Class Reference 43

Overview 43Tasks 43Properties 43

Chapter 9 Touch Class Reference 47

Overview 47Tasks 47Properties 48

Chapter 10 TouchEvent Class Reference 51

Overview 51Tasks 51Properties 52Methods 52

Chapter 11 TouchList Class Reference 55

Overview 55Tasks 55Properties 55Methods 56

Chapter 12 WebKitAnimationEvent Class Reference 57

Overview 57Tasks 58Properties 58Methods 59

Chapter 13 WebKitCSSKeyframeRule Class Reference 61

Overview 61Tasks 61Properties 61

42010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CONTENTS

Page 5: Safari JS reference

Chapter 14 WebKitCSSKeyframesRule Class Reference 63

Overview 63Tasks 63Properties 64Methods 64

Chapter 15 WebKitCSSMatrix Class Reference 67

Overview 67Tasks 67Properties 69Methods 75

Chapter 16 WebKitCSSTransformValue Class Reference 79

Overview 79Tasks 79Properties 79Constants 80

Chapter 17 WebKitPoint Class Reference 83

Overview 83Tasks 83Properties 83

Chapter 18 WebKitTransitionEvent Class Reference 85

Overview 85Tasks 85Properties 86Methods 86

Document Revision History 89

52010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CONTENTS

Page 6: Safari JS reference

62010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CONTENTS

Page 7: Safari JS reference

Tables

Chapter 4 DOMWindow Additions Reference 23

Table 4-1 Window orientation values 24

Chapter 7 HTMLMediaElement Class Reference 31

Table 7-1 Media element events 31

72010-05-19 | © 2010 Apple Inc. All Rights Reserved.

Page 8: Safari JS reference

82010-05-19 | © 2010 Apple Inc. All Rights Reserved.

TABLES

Page 9: Safari JS reference

Note: This document was previously titled Safari DOM Extensions Reference.

This covers miscellaneous DOM extensions used by Safari on the desktop and Safari on iOS. These extensionsinclude DOM touch events for processing gestures for devices that have a touch screen and visual effectsthat support 2D and 3D transforms, animation, and transitions. Most of the classes described in this referenceare Apple extensions that may also be proposed W3C standards.

See Also

There are a variety of other resources for Safari web content developers using JavaScript.

If you are using DOM touch events, you should also read:

■ Safari Web Content Guide, which describes how to create web content and applications for Safari on allplatforms.

If you are using visual effects, you should read:

■ Safari CSS Visual Effects Guide, which describes how to use the CSS transition, animation, and transformproperties.

If you want to use the JavaScript database classes, you should read:

■ Safari Client-Side Storage andOffline Applications ProgrammingGuide, which describes a simple relationaldatabase that you can use to store persistent data in JavaScript that cannot be stored in cookies.

If you want to use the JavaScript media APIs, then you should read:

■ JavaScript Scripting Guide for QuickTime, which describes how to use JavaScript to query and control theQuickTime plug-in directly.

If you want access to the DOM or use the canvas object, then read:

■ WebKitDOMProgrammingTopics, which describes how to use JavaScript in web content for WebKit-basedapplications.

■ WebKit DOM Reference, which describes the API for accessing the WebKit Document Object Model.

If you want to read the WebKit W3C proposals then go to: http://www.webkit.org/specs.

See Also 92010-05-19 | © 2010 Apple Inc. All Rights Reserved.

INTRODUCTION

Safari DOM Additions Reference

Page 10: Safari JS reference

10 See Also2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

INTRODUCTION

Safari DOM Additions Reference

Page 11: Safari JS reference

112010-05-19 | © 2010 Apple Inc. All Rights Reserved.

PART I

Classes

Page 12: Safari JS reference

122010-05-19 | © 2010 Apple Inc. All Rights Reserved.

PART I

Classes

Page 13: Safari JS reference

Availability Available in Safari 4.0 and later.Available in iOS 2.0 and later.

Companion guide Safari CSS Visual Effects Guide

Overview

These extensions to the CSSRule class are used to access animation keyframe and keyframes rules.

Constants

DescriptionConstant

Keyframes rule type. Read WebKitCSSKeyframesRule for details.const unsigned short WEBKIT_KEYFRAMES_RULE = 7;

Safari Note: In Safari 4.0 and later, the value is 8.

Available in Safari 4.0 and later.Available in iOS 2.0 and later.

WEBKIT_KEYFRAMES_-RULE

Keyframe rule type. Read WebKitCSSKeyframeRule for details.const unsigned short WEBKIT_KEYFRAME_RULE = 8;

Safari Note: In Safari 4.0 and later, the value is 9.

Available in Safari 4.0 and later.Available in iOS 2.0 and later.

WEBKIT_KEYFRAME_RULE

Overview 132010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 1

CSSRule Additions Reference

Page 14: Safari JS reference

14 Constants2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 1

CSSRule Additions Reference

Page 15: Safari JS reference

Availability Available in iOS 2.0 and later.

Companion guide Safari Web Content Guide

Overview

These additions to the Document class are used to create touch event objects.

Tasks

Creating Touches

createTouch (page 15)Creates a new Touch object.

createTouchList (page 16)Creates a new TouchList object.

Methods

createTouchCreates a new Touch object.

Touch createTouch(in DOMWindow view, in EventTarget target, in long identifier, in long pageX, in long pageY, in long screenX, in long screenY) raises (

DOMException);

Parametersview

The view (DOM window) in which the event occurred.

Overview 152010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 2

Document Additions Reference

Page 16: Safari JS reference

targetThe target of this gesture.

identifierThe unique identifier for this touch object.

pageXThe x-coordinate of the touch’s location, in page coordinates.

pageYThe y-coordinate of the touch’s location, in page coordinates.

screenXThe x-coordinate of the event’s location, in screen coordinates.

screenYThe y-coordinate of the event’s location, in screen coordinates.

AvailabilityAvailable in iOS 2.0 and later.

createTouchListCreates a new TouchList object.

TouchList createTouchList() raises ( DOMException);

AvailabilityAvailable in iOS 2.0 and later.

16 Methods2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 2

Document Additions Reference

Page 17: Safari JS reference

Availability Available in Safari 4.0 and later.Available in iOS 2.2 and later.

Companion guide Safari Web Content Guide

Overview

A DOMApplicationCache object is used to store resources—such as, HTML, JavaScript, CSS, andimages—locally. This allows your web application to continue running offline when there is no networkconnection. The cache persists after Safari exits, so it can be used by multiple browser sessions. There is oneapplication cache per browsing context.

Tasks

Accessing Properties

status (page 19)The current status of the application cache. One of the values described in "Constants.”

Handling Events

onchecking (page 18)Sent when the cache update process begins.

onerror (page 19)Sent when an error occurs.

onnoupdate (page 19)Sent when the update process finishes but the manifest file does not change.

ondownloading (page 18)Sent when the update process begins downloading resources in the manifest file.

onprogress (page 19)Sent when each resource in the manifest file begins to download.

onupdateready (page 19)Sent when there is an existing application cache, the update process finishes, and there is a newapplication cache ready for use.

Overview 172010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 3

DOMApplicationCache Class Reference

Page 18: Safari JS reference

oncached (page 18)Sent when the update process finishes for the first time—that is, the first time an application cacheis saved.

Updating the Cache

add (page 20)Forthcoming

update (page 20)Manually triggers the update process.

swapCache (page 20)Replaces the active cache with the latest version.

Properties

oncachedSent when the update process finishes for the first time—that is, the first time an application cache is saved.

attribute EventListener oncached;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.2 and later.

oncheckingSent when the cache update process begins.

attribute EventListener onchecking;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.2 and later.

ondownloadingSent when the update process begins downloading resources in the manifest file.

attribute EventListener ondownloading;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.2 and later.

18 Properties2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 3

DOMApplicationCache Class Reference

Page 19: Safari JS reference

onerrorSent when an error occurs.

attribute EventListener onerror;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.2 and later.

onnoupdateSent when the update process finishes but the manifest file does not change.

attribute EventListener onnoupdate;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.2 and later.

onprogressSent when each resource in the manifest file begins to download.

attribute EventListener onprogress;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.2 and later.

onupdatereadySent when there is an existing application cache, the update process finishes, and there is a new applicationcache ready for use.

attribute EventListener onupdateready;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.2 and later.

statusThe current status of the application cache. One of the values described in "Constants.”

readonly attribute unsigned short status;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.2 and later.

Properties 192010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 3

DOMApplicationCache Class Reference

Page 20: Safari JS reference

Methods

addForthcoming

void add(in DOMString uri) raises(DOMException);

DiscussionForthcoming

AvailabilityAvailable in Safari 4.0 through Safari 4.0.2.

swapCacheReplaces the active cache with the latest version.

void swapCache() raises(DOMException);

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.2 and later.

updateManually triggers the update process.

void update() raises(DOMException);

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.2 and later.

Constants

Constants that indicate the status of the application cache.

DescriptionConstant

The object isn’t associated with an application cache. This can occur if the update processfails and there is no previous cache to revert to, or if there is no manifest file.

const unsigned short UNCACHED = 0;

Available in Safari 4.0 and later.Available in iOS 2.2 and later.

UNCACHED

20 Methods2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 3

DOMApplicationCache Class Reference

Page 21: Safari JS reference

DescriptionConstant

The cache is idle.const unsigned short IDLE = 1;

Available in Safari 4.0 and later.Available in iOS 2.2 and later.

IDLE

The update has started but the resources are not downloaded yet—for example, this canhappen when the manifest file is fetched.

const unsigned short CHECKING = 2;

Available in Safari 4.0 and later.Available in iOS 2.2 and later.

CHECKING

The resources are being downloaded into the cache.const unsigned short DOWNLOADING = 3;

Available in Safari 4.0 and later.Available in iOS 2.2 and later.

DOWNLOADING

Resources have finished downloading and the new cache is ready to be used.const unsigned short UPDATEREADY = 4;

Available in Safari 4.0 and later.Available in iOS 2.2 and later.

UPDATEREADY

Constants 212010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 3

DOMApplicationCache Class Reference

Page 22: Safari JS reference

22 Constants2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 3

DOMApplicationCache Class Reference

Page 23: Safari JS reference

Availability Available in Safari 4.0 and later.Available in iOS 1.1.1 and later.

Companion guides Safari Web Content GuideSafari CSS Visual Effects Guide

Overview

DOMWindow additions allow conversion of points from page- and node-coordinate systems for transitions.

Tasks

Accessing Properties

applicationCache (page 23)The application cache associated with the current document.

orientation (page 24)Specifies the orientation of the device.

Converting Points

webkitConvertPointFromPageToNode (page 25)Converts a point from page coordinates to a given node’s coordinates.

webkitConvertPointFromNodeToPage (page 24)Converts a point from a given node’s coordinates to page coordinates.

Properties

applicationCacheThe application cache associated with the current document.

Overview 232010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 4

DOMWindow Additions Reference

Page 24: Safari JS reference

readonly attribute DOMApplicationCache applicationCache;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.2 and later.

orientationSpecifies the orientation of the device.

readonly attribute long orientation;

DiscussionThis property is set to one of the values in Table 4-1 (page 24). For example, if the user starts with the devicein portrait orientation and then changes to landscape orientation by turning the device to the right, thewindow’s orientation property is set to -90. If the user instead changes to landscape by turning the deviceto the left, the window’s orientation property is set to 90. The default value is 0.

Table 4-1 Window orientation values

DescriptionValue

Portrait orientation. This is the default value.0

Landscape orientation with the screen turned clockwise.-90

Landscape orientation with the screen turned counterclockwise.90

Portrait orientation with the screen turned upside down. This value is currently not supported oniPhone.

180

AvailabilityAvailable in iPhone 1.1.1 and later.

Methods

webkitConvertPointFromNodeToPageConverts a point from a given node’s coordinates to page coordinates.

WebKitPoint webkitConvertPointFromNodeToPage(in Node node, in WebKitPoint p);

Parametersnode

The coordinate space for p.

pA point in node’s coordinates to convert to page coordinates.

Return ValueA point that is at the same location as p but in the page coordinates.

24 Methods2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 4

DOMWindow Additions Reference

Page 25: Safari JS reference

AvailabilityAvailable in iOS 2.0 and later.

webkitConvertPointFromPageToNodeConverts a point from page coordinates to a given node’s coordinates.

WebKitPoint webkitConvertPointFromPageToNode(in Node node, in WebKitPoint p);

Parametersnode

The coordinate space to convert the given point to.

pA point in page coordinates to convert to node’s coordinates.

Return ValueA point that is at the same location as p but in the node’s coordinates.

AvailabilityAvailable in iOS 2.0 and later.

Methods 252010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 4

DOMWindow Additions Reference

Page 26: Safari JS reference

26 Methods2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 4

DOMWindow Additions Reference

Page 27: Safari JS reference

Inherits from UIEvent

Availability Available in iOS 2.0 and later.

Companion guide Safari Web Content Guide

Overview

The GestureEvent class encapsulates information about a multi-touch gesture.

GestureEvent objects are high-level events that encapsulate the low-level TouchEvent objects. BothGestureEvent and TouchEvent events are sent during a multi-touch sequence. Gesture events containscaling and rotation information allowing gestures to be combined, if supported by the platform. If notsupported, one gesture ends before another starts. Listen for GestureEvent events if you want to respondto gestures only, not process the low-level TouchEvent objects.

The different types of GestureEvent objects that can occur are:

gesturestartSent when two or more fingers touch the surface.

gesturechangeSent when fingers are moved during a gesture.

gestureendSent when the gesture ends (when there are 1 or 0 fingers touching the surface).

For example, for a two finger multi-touch gesture, the events occur in the following sequence:

1. touchstart for finger 1. Sent when the first finger touches the surface.

2. gesturestart. Sent when the second finger touches the surface.

3. touchstart for finger 2. Sent immediately after gesturestart when the second finger touches thesurface.

4. gesturechange for current gesture. Sent when both fingers move while still touching the surface.

5. gestureend. Sent when the second finger lifts from the surface.

6. touchend for finger 2. Sent immediately after gestureendwhen the second finger lifts from the surface.

7. touchend for finger 1. Sent when the first finger lifts from the surface.

See TouchEvent Class Reference if you want to process just low-level TouchEvent objects.

Overview 272010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 5

GestureEvent Class Reference

Page 28: Safari JS reference

28 Overview2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 5

GestureEvent Class Reference

Page 29: Safari JS reference

Inherits from HTMLMediaElement

Availability Available in Safari 3.1 and later.Available in iOS 3.0 and later.

Overview

A class representing the HTML audio element that plays a sound or audio stream in a webpage. All of themethods and properties in this class are inherited from HTMLMediaElement.

Overview 292010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 6

HTMLAudioElement Class Reference

Page 30: Safari JS reference

30 Overview2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 6

HTMLAudioElement Class Reference

Page 31: Safari JS reference

Availability Available in Safari 3.1 and later.Available in iOS 3.0 and later.

Overview

An abstract superclass for media classes that display audio or video in webpages. This class defines commonproperties and methods inherited by the HTMLAudioElement and HTMLVideoElement classes representingthe HTML audio and video elements.

The different types of media events that can occur are described in Table 7-1.

Table 7-1 Media element events

DescriptionEvent

Sent when the browser stops fetching the media data before the media resource wascompletely downloaded.

abort

Sent when the browser can resume playback of the media data, but estimates that ifplayback is started now, the media resource could not be rendered at the currentplayback rate up to its end without having to stop for further buffering of content.

canplay

Sent when the browser estimates that if playback is started now, the media resourcecould be rendered at the current playback rate all the way to its end without havingto stop for further buffering.

canplaythrough

Sent when the duration (page 36) property changes.durationchange

Sent when the media element network state changes to the NETWORK_EMPTY (page41) state.

emptied

Sent when playback has stopped at the end of the media resource and the ended (page36) property is set to true.

ended

Sent when an error occurs while fetching the media data. Use the error (page 36)property to get the current error.

error

Sent when the browser can render the media data at the current playback positionfor the first time.

loadeddata

Sent when the browser knows the duration and dimensions of the media resource.loadedmetadata

Sent when the browser begins loading the media data.loadstart

Overview 312010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 7

HTMLMediaElement Class Reference

Page 32: Safari JS reference

DescriptionEvent

Sent when playback pauses after the pause (page 40) method returns.pause

Sent when playback starts after the play (page 40) method returns.play

Sent when playback starts.playing

Sent when the browser is fetching the media data.progress

Sent when either the defaultPlaybackRate (page 35) or the playbackRate (page37) property changes.

ratechange

Sent when the seeking (page 38) property is set to falseseeked

Sent when the seeking (page 38) property is set to true and there is time to sendthis event.

seeking

Sent when the browser is fetching media data but it has stopped arriving.stalled

Sent when the browser suspends loading the media data and does not have the entiremedia resource downloaded.

suspend

Sent when the currentTime (page 35) property changes as part of normal playbackor because of some other condition.

timeupdate

Sent when either the volume (page 39) property or the muted (page 37) propertychanges.

volumechange

Sent when the browser stops playback because it is waiting for the next frame.waiting

Tasks

Getting and Setting Properties

autobuffer (page 34)A Boolean value that gives a hint to the browser that it should automatically buffer media when thewebpage is loaded.

autoplay (page 34)A Boolean value that determines whether the media resource plays automatically when available.

controls (page 34)A Boolean value that determines whether the playback controls appear.

currentTime (page 35)The current playback position in seconds.

defaultPlaybackRate (page 35)The default rate used to play the media resource.

loop (page 36)A Boolean value that determines whether the playback should loop.

32 Tasks2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 7

HTMLMediaElement Class Reference

Page 33: Safari JS reference

muted (page 37)A Boolean value that determines whether the audio content should be muted.

playbackRate (page 37)The speed that the media resource is playing.

src (page 38)The URI address of the media resource to play.

volume (page 39)The volume of the audio portion of the media element.

Getting State

buffered (page 34)The time ranges of the media resource that have been downloaded. (read-only)

currentSrc (page 35)The absolute URL of the media resource. (read-only)

duration (page 36)The length of the media resource in seconds. (read-only)

ended (page 36)A Boolean value that indicates whether the media played to the end. (read-only)

error (page 36)The last error that occurred for this element. (read-only)

networkState (page 37)The state of downloading the media resource. (read-only)

paused (page 37)A Boolean value that indicates whether the media is paused. (read-only)

played (page 38)The ranges of the media resource that was played. (read-only)

readyState (page 38)The ready state of the media resource. (read-only)

seekable (page 38)The ranges that can be played in a nonlinear fashion. (read-only)

seeking (page 38)A Boolean value that indicates whether the element is seeking. (read-only)

startTime (page 39)The earliest possible time in seconds to start playback. (read-only)

Controlling Playback

canPlayType (page 39)Returns whether the media element supports the specified MIME type.

load (page 39)Starts loading the media resource.

Tasks 332010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 7

HTMLMediaElement Class Reference

Page 34: Safari JS reference

pause (page 40)Pauses the media playback if in progress.

play (page 40)Begins playing the media resource.

Properties

autobufferA Boolean value that gives a hint to the browser that it should automatically buffer media when the webpageis loaded.

attribute boolean autobuffer;

DiscussionIf true (the default), the media data is automatically buffered; otherwise, it is not.

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 3.0 and later.

autoplayA Boolean value that determines whether the media resource plays automatically when available.

attribute boolean autoplay;

DiscussionIf false (the default), the media resource does not automatically play when loaded; otherwise, it does.

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

bufferedThe time ranges of the media resource that have been downloaded. (read-only)

readonly attribute TimeRanges buffered;

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

controlsA Boolean value that determines whether the playback controls appear.

34 Properties2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 7

HTMLMediaElement Class Reference

Page 35: Safari JS reference

attribute boolean controls;

DiscussionOn the desktop, if false (the default), the playback controls do not appear; otherwise, they do appear. OniOS, a native application is used to playback video in full screen; therefore, this property is ignored.

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

currentSrcThe absolute URL of the media resource. (read-only)

readonly attribute DOMString currentSrc;

DiscussionThis property is an empty string if the networkState (page 37) property is NETWORK_EMPTY (page 41).

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

currentTimeThe current playback position in seconds.

attribute float currentTime setter raises (DOMException);

DiscussionWhen you set this property, the media play head moves to the new location. An INVALID_STATE_ERR DOMexception is raised if there is no selected media resource when you set this property. An INDEX_SIZE_ERRDOM exception is raised if the specified time is not within the start and end times.

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

defaultPlaybackRateThe default rate used to play the media resource.

attribute float defaultPlaybackRate;

DiscussionThe value of this property is a multiple of the media resource’s intrinsic speed. The default value is 1.0.

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

Properties 352010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 7

HTMLMediaElement Class Reference

Page 36: Safari JS reference

durationThe length of the media resource in seconds. (read-only)

readonly attribute float duration;

DiscussionThis property is 0 if there is no media data available. This property is NaN if the duration is unknown. Thevalue is positive infinity if the duration is known but is indefinite—for example, a live stream.

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

endedA Boolean value that indicates whether the media played to the end. (read-only)

readonly attribute boolean ended;

DiscussionIf true, the video played to the end; otherwise, it did not.

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

errorThe last error that occurred for this element. (read-only)

readonly attribute MediaError error;

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

loopA Boolean value that determines whether the playback should loop.

attribute boolean loop;

DiscussionIf true, the playback should loop; otherwise, it should not.

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

36 Properties2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 7

HTMLMediaElement Class Reference

Page 37: Safari JS reference

mutedA Boolean value that determines whether the audio content should be muted.

attribute boolean muted;

DiscussionIf true, the audio track is muted; otherwise, it is not.

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

networkStateThe state of downloading the media resource. (read-only)

readonly attribute unsigned short networkState;

DiscussionPossible values are described in “Constants.”

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

pausedA Boolean value that indicates whether the media is paused. (read-only)

readonly attribute boolean paused;

DiscussionIf true, the video is paused; otherwise, it is not.

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

playbackRateThe speed that the media resource is playing.

attribute float playbackRate;

DiscussionThe value of this property is a multiple of the media resource’s intrinsic speed. If set to 0.0, aNOT_SUPPORTED_ERR DOM exception is raised. The default value is 1.0.

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

Properties 372010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 7

HTMLMediaElement Class Reference

Page 38: Safari JS reference

playedThe ranges of the media resource that was played. (read-only)

readonly attribute TimeRanges played;

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

readyStateThe ready state of the media resource. (read-only)

readonly attribute unsigned short readyState;

DiscussionPossible values are described in “Constants.”

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

seekableThe ranges that can be played in a nonlinear fashion. (read-only)

readonly attribute TimeRanges seekable;

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

seekingA Boolean value that indicates whether the element is seeking. (read-only)

readonly attribute boolean seeking;

DiscussionIf true, the media resource is playing in a nonlinear fashion; otherwise, it is not.

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

srcThe URI address of the media resource to play.

38 Properties2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 7

HTMLMediaElement Class Reference

Page 39: Safari JS reference

attribute DOMString src;

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

startTimeThe earliest possible time in seconds to start playback. (read-only)

readonly attribute float startTime;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 3.0 and later.

volumeThe volume of the audio portion of the media element.

attribute float volume setter raises (DOMException);

DiscussionThe value of this property must be in the range from 0.0 (silent) to 1.0 (loudest); otherwise, aINDEX_SIZE_ERR DOM exception is raised. The default value is 1.0.

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

Methods

canPlayTypeReturns whether the media element supports the specified MIME type.

DOMString canPlayType(in DOMString type);

Return ValueThe possible string values are: “no”, “probably” and “maybe”.

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 3.0 and later.

loadStarts loading the media resource.

Methods 392010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 7

HTMLMediaElement Class Reference

Page 40: Safari JS reference

void load() raises (DOMException);

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

pausePauses the media playback if in progress.

void pause();

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

playBegins playing the media resource.

void play();

DiscussionIf the media resource is not available for playback, this method loads it.

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

Constants

Possible values for the readyState (page 38) property.

DescriptionConstant

No media data is available for playback at the current time.const unsigned short HAVE_NOTHING = 0;

Available in Safari 3.1 and later.Available in iOS 3.0 and later.

HAVE_NOTHING

Enough of the media resource has been loaded to know the duration, and in thecase of a video element, the dimensions.

const unsigned short HAVE_METADATA = 1;

Available in Safari 3.1 and later.Available in iOS 3.0 and later.

HAVE_METADATA

40 Constants2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 7

HTMLMediaElement Class Reference

Page 41: Safari JS reference

DescriptionConstant

Data for the current playback position is available, but not enough to beginplayback.

const unsigned short HAVE_CURRENT_DATA = 2;

Available in Safari 3.1 and later.Available in iOS 3.0 and later.

HAVE_CURRENT_DATA

Enough data is available to begin playback.const unsigned short HAVE_FUTURE_DATA = 3;

Available in Safari 3.1 and later.Available in iOS 3.0 and later.

HAVE_FUTURE_DATA

Enough data is available to play at the default playback rate to the end of themedia resource without having to pause to rebuffer.

const unsigned short HAVE_ENOUGH_DATA = 4;

Available in Safari 3.1 and later.Available in iOS 3.0 and later.

HAVE_ENOUGH_DATA

Possible values for the networkState (page 37) property.

DescriptionConstant

The element is not initialized.const unsigned short NETWORK_EMPTY = 0;

Available in Safari 3.1 and later.Available in iOS 3.0 and later.

NETWORK_EMPTY

The network connection is idle.const unsigned short NETWORK_IDLE = 1;

Available in Safari 3.1 and later.Available in iOS 3.0 and later.

NETWORK_IDLE

The media resource is loading.const unsigned short NETWORK_LOADING = 2;

Available in Safari 3.1 and later.Available in iOS 3.0 and later.

NETWORK_LOADING

The media source finished loading.const unsigned short NETWORK_LOADED = 3;

Available in Safari 3.1 and later.Available in iOS 3.0 and later.

NETWORK_LOADED

Constants 412010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 7

HTMLMediaElement Class Reference

Page 42: Safari JS reference

DescriptionConstant

No media resource was found.const unsigned short NETWORK_NO_SOURCE = 4;

Available in Safari 3.1 and later.Available in iOS 3.0 and later.

NETWORK_NO_SOURCE

42 Constants2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 7

HTMLMediaElement Class Reference

Page 43: Safari JS reference

Inherits from HTMLMediaElement

Availability Available in Safari 3.1 and later.Available in iOS 3.0 and later.

Overview

A class representing the HTML video element that plays a video or movie in a webpage. Use theHTMLAudioElement class for the HTML audio element.

Tasks

Getting and Setting Properties

width (page 44)The width of the video element in CSS pixels.

height (page 43)The height of the video element in CSS pixels.

poster (page 44)The URI address of an image file that is shown when no video data is available.

Getting State

videoWidth (page 44)The native width of the video in CSS pixels. (read-only)

videoHeight (page 44)The native height of the video in CSS pixels. (read-only)

Properties

heightThe height of the video element in CSS pixels.

Overview 432010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 8

HTMLVideoElement Class Reference

Page 44: Safari JS reference

attribute unsigned long height;

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

posterThe URI address of an image file that is shown when no video data is available.

attribute [ConvertNullToNullString] DOMString poster;

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

videoHeightThe native height of the video in CSS pixels. (read-only)

readonly attribute unsigned long videoHeight;

DiscussionIf no video data is available, this property is 0.

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

videoWidthThe native width of the video in CSS pixels. (read-only)

readonly attribute unsigned long videoWidth;

DiscussionIf no video data is available, this property is 0.

AvailabilityAvailable in Safari 3.1 and later.Available in iOS 3.0 and later.

widthThe width of the video element in CSS pixels.

attribute unsigned long width;

AvailabilityAvailable in Safari 3.1 and later.

44 Properties2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 8

HTMLVideoElement Class Reference

Page 45: Safari JS reference

Available in iOS 3.0 and later.

Properties 452010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 8

HTMLVideoElement Class Reference

Page 46: Safari JS reference

46 Properties2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 8

HTMLVideoElement Class Reference

Page 47: Safari JS reference

Availability Available in iOS 2.0 and later.

Companion guide Safari Web Content Guide

Overview

The Touch class represents a single touch on the surface. A touch is the presence or movement of a fingerthat is part of a unique multi-touch sequence. Use the changedTouches (page 52) method to get all thetouch objects that changed in a TouchEvent object.

Tasks

Accessing Properties

clientX (page 48)The x-coordinate of the touch’s location relative to the window’s viewport.

clientY (page 48)The y-coordinate of the touch’s location relative to the window’s viewport.

identifier (page 48)The unique identifier for this touch object.

pageX (page 48)The x-coordinate of the touch’s location in page coordinates.

pageY (page 48)The y-coordinate of the touch’s location in page coordinates.

screenX (page 49)The x-coordinate of the touch’s location in screen coordinates.

screenY (page 49)The y-coordinate of the touch’s location in screen coordinates.

target (page 49)The target of this touch.

Overview 472010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 9

Touch Class Reference

Page 48: Safari JS reference

Properties

clientXThe x-coordinate of the touch’s location relative to the window’s viewport.

readonly attribute long clientX;

AvailabilityAvailable in iOS 2.0 and later.

clientYThe y-coordinate of the touch’s location relative to the window’s viewport.

readonly attribute long clientY;

AvailabilityAvailable in iOS 2.0 and later.

identifierThe unique identifier for this touch object.

readonly attribute unsigned long identifier;

AvailabilityAvailable in iOS 2.0 and later.

pageXThe x-coordinate of the touch’s location in page coordinates.

readonly attribute long pageX;

AvailabilityAvailable in iOS 2.0 and later.

pageYThe y-coordinate of the touch’s location in page coordinates.

readonly attribute long pageY;

AvailabilityAvailable in iOS 2.0 and later.

48 Properties2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 9

Touch Class Reference

Page 49: Safari JS reference

screenXThe x-coordinate of the touch’s location in screen coordinates.

readonly attribute long screenX;

AvailabilityAvailable in iOS 2.0 and later.

screenYThe y-coordinate of the touch’s location in screen coordinates.

readonly attribute long screenY;

AvailabilityAvailable in iOS 2.0 and later.

targetThe target of this touch.

readonly attribute EventTarget target;

AvailabilityAvailable in iOS 2.0 and later.

Properties 492010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 9

Touch Class Reference

Page 50: Safari JS reference

50 Properties2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 9

Touch Class Reference

Page 51: Safari JS reference

Inherits from UIEvent

Availability Available in iOS 2.0 and later.

Companion guide Safari Web Content Guide

Overview

The TouchEvent class encapsulates information about a touch event.

The system continually sends TouchEvent objects to an application as fingers touch and move across asurface. A touch event provides a snapshot of all touches during a multi-touch sequence, most importantlythe touches that are new or have changed for a particular target. A multi-touch sequence begins when afinger first touches the surface. Other fingers may subsequently touch the surface, and all fingers may moveacross the surface. The sequence ends when the last of these fingers is lifted from the surface. An applicationreceives touch event objects during each phase of any touch.

The different types of TouchEvent objects that can occur are:

touchstartSent when a finger for a given event touches the surface.

touchmoveSent when a given event moves on the surface.

touchendSent when a given event lifts from the surface.

touchcancelSent when the system cancels tracking for the touch.

TouchEvent objects are combined together to form high-level GestureEvent objects that are also sentduring a multi-touch sequence. See GestureEvent for details on GestureEvent objects and an exampleof the events sent for a two finger multi-touch gesture.

Tasks

Accessing Properties

altKey (page 52)If true, the alt key is pressed; otherwise, it is not. If there is no keyboard, this value is false.

Overview 512010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 10

TouchEvent Class Reference

Page 52: Safari JS reference

changedTouches (page 52)A collection of Touch objects representing all touches that changed in this event.

Initializing

initTouchEvent (page 52)Initializes a newly created TouchEvent object.

Properties

altKeyIf true, the alt key is pressed; otherwise, it is not. If there is no keyboard, this value is false.

readonly attribute boolean altKey;

AvailabilityAvailable in iOS 2.0 and later.

changedTouchesA collection of Touch objects representing all touches that changed in this event.

readonly attribute TouchList changedTouches;

DiscussionYou manipulate this collection using TouchList methods.

AvailabilityAvailable in iOS 2.0 and later.

Methods

initTouchEventInitializes a newly created TouchEvent object.

52 Properties2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 10

TouchEvent Class Reference

Page 53: Safari JS reference

void initTouchEvent(in DOMString type, in boolean canBubble, in boolean cancelable, in DOMWindow view, in long detail, in long screenX, in long screenY, in long clientX, in long clientY, in boolean ctrlKey, in boolean altKey, in boolean shiftKey, in boolean metaKey, in TouchList touches, in TouchList targetTouches, in TouchList changedTouches, in float scale, in float rotation);

Parameterstype

The type of event that occurred.

canBubbleIndicates whether an event can bubble. If true, the event can bubble; otherwise, it cannot.

cancelableIndicates whether an event can have its default action prevented. If true, the default action can beprevented; otherwise, it cannot.

viewThe view (DOM window) in which the event occurred.

detailSpecifies some detail information about the event depending on the type of event.

screenXThe x-coordinate of the event’s location in screen coordinates.

screenYThe y-coordinate of the event’s location in screen coordinates.

clientXThe x-coordinate of the event’s location relative to the window’s viewport.

clientYThe y-coordinate of the event’s location relative to the window’s viewport.

ctrlKeyIf true, the control key is pressed; otherwise, it is not.

altKeyIf true, the alt key is pressed; otherwise, it is not.

shiftKeyIf true, the shift key is pressed; otherwise, it is not.

metaKeyIf true, the meta key is pressed; otherwise, it is not.

Methods 532010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 10

TouchEvent Class Reference

Page 54: Safari JS reference

touchesA collection of Touch objects representing all touches associated with this event.

targetTouchesA collection of Touch objects representing all touches associated with this target.

changedTouchesA collection of Touch objects representing all touches that changed in this event.

scaleThe distance between two fingers since the start of an event as a multiplier of the initial distance. Theinitial value is 1.0. If less than 1.0, the gesture is pinch close (to zoom out). If greater than 1.0, thegesture is pinch open (to zoom in).

rotationThe delta rotation since the start of an event, in degrees, where clockwise is positive andcounter-clockwise is negative. The initial value is 0.0.

DiscussionUse this method to programmatically create a TouchEvent object.

AvailabilityAvailable in iOS 2.0 and later.

54 Methods2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 10

TouchEvent Class Reference

Page 55: Safari JS reference

Availability Available in iOS 2.0 and later.

Companion guide Safari Web Content Guide

Overview

The TouchList class is used to represent a collection of Touch objects. For example, thechangedTouches (page 52) method in TouchEvent returns a TouchList object.

Tasks

Accessing Properties

length (page 55)The number of Touch objects in this TouchList object.

Getting Touch Objects

item (page 56)Returns the Touch object at the given index.

Properties

lengthThe number of Touch objects in this TouchList object.

readonly attribute unsigned long length;

AvailabilityAvailable in iOS 2.0 and later.

Overview 552010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 11

TouchList Class Reference

Page 56: Safari JS reference

Methods

itemReturns the Touch object at the given index.

Touch item(in unsigned long index);

Parametersindex

The index of the item to return.

AvailabilityAvailable in iOS 2.0 and later.

56 Methods2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 11

TouchList Class Reference

Page 57: Safari JS reference

Inherits from Event

Availability Available in Safari 4.0 and later.Available in iOS 2.0 and later.

Companion guide Safari CSS Visual Effects Guide

Overview

WebKitAnimationEvent objects encapsulate information about running animations.

Several animation related events are available through the DOM Event system. The start and end of ananimation, and the end of each iteration of an animation all generate DOM events. An element can havemultiple properties that are animated simultaneously. This simultaneous animation can occur either by settinga single -webkit-animation-name value with keyframes containing multiple properties, or by settingmultiple -webkit-animation-name values. For the purposes of event dispatching, each CSS-webkit-animation-name property specifies a single animation. Therefore, an event is sent for each-webkit-animation-name property, not necessarily for each CSS property that is animated.

Each event contains the duration of the animation. This allows the event handler to determine the currentiteration of a looping animation or the current position of an alternating animation. This duration does notinclude time the animation was in the paused play state.

Types of Animation Events

The type property of an animation event can have the following string values:

webkitAnimationStartOccurs at the start of an animation. It can bubble and be canceled. Its animationName property isset.

webkitAnimationEndOccurs when the animation finishes. It can bubble and be canceled. Its animationName andelapsedTime properties are set.

webkitAnimationIterationOccurs at the end of each iteration of an animation when the-webkit-animation-iteration-count is greater than 1. It does not occur for animations withan iteration count of 1. It can bubble and be canceled. Its animationName and elapsedTimeproperties are set.

Overview 572010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 12

WebKitAnimationEvent Class Reference

Page 58: Safari JS reference

Tasks

Accessing Properties

animationName (page 58)The name of the animation. The value of the CSS -webkit-animation-name property of theanimation that caused the event.

elapsedTime (page 58)The duration of the animation, in seconds, since this event was sent, excluding any time the animationis paused. This value is not affected by the value of the CSS -webkit-animation-delay property.If the type of the event is webkitAnimationStart, elapsedTime is 0.

Initializing Objects

initWebKitAnimationEvent (page 59)Initializes a new animation event object.

Properties

animationNameThe name of the animation. The value of the CSS -webkit-animation-name property of the animationthat caused the event.

readonly attribute DOMString animationName;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.0 and later.

elapsedTimeThe duration of the animation, in seconds, since this event was sent, excluding any time the animation ispaused. This value is not affected by the value of the CSS -webkit-animation-delay property. If the typeof the event is webkitAnimationStart, elapsedTime is 0.

readonly attribute double elapsedTime;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.0 and later.

58 Tasks2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 12

WebKitAnimationEvent Class Reference

Page 59: Safari JS reference

Methods

initWebKitAnimationEventInitializes a new animation event object.

void initWebKitAnimationEvent(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in DOMString animationNameArg, in doubleelapsedTimeArg);

ParameterstypeArg

The type of event. See “Types of Animation Events” (page 57) for possible values.

canBubbleArgDetermines whether the event can bubble. Pass true if it can bubble; otherwise, false.

cancelableArgDetermines whether the event’s default action can be prevented. Pass true if it can be prevented;otherwise, false.

animationNameArgThe name of the animation associated with this event.

elapsedTimeArgThe duration of the animation, in seconds, since the event was sent.

DiscussionYou use this method to initialize the value of a WebKitTransitionEvent object that is created throughthe DocumentEvent interface. This method can only be invoked before the WebKitTransitionEventobject is dispatched via the dispatchEvent method (although it can be invoked multiple times during thatphase, if necessary). If it is invoked multiple times, the final invocation takes precedence.

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.0 and later.

Methods 592010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 12

WebKitAnimationEvent Class Reference

Page 60: Safari JS reference

60 Methods2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 12

WebKitAnimationEvent Class Reference

Page 61: Safari JS reference

Inherits from CSSRule

Availability Available in Safari 4.0 and later.Available in iOS 2.0 and later.

Companion guide Safari CSS Visual Effects Guide

Overview

WebKitCSSKeyframeRule objects represent the style rule for a single keyframe in the @-webkit-keyframesCSS rule used in animations. The WebKitAnimationEvent class encapsulate information about runninganimations.

Tasks

Accessing Properties

keyText (page 61)A keyframe selector.

style (page 62)The style associated with this keyframe.

Properties

keyTextA keyframe selector.

attribute DOMString keyText;

DiscussionA keyframe selector represented as a percentage value or the keyword from or to. The selector is used tospecify the percentage along the duration of the animation. The keyframe is specified by the block of propertyvalues declared for the selector. The keyword from is equivalent to 0 percent and to is equivalent to 100percent.

Overview 612010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 13

WebKitCSSKeyframeRule Class Reference

Page 62: Safari JS reference

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.0 and later.

styleThe style associated with this keyframe.

readonly attribute CSSStyleDeclaration style;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.0 and later.

62 Properties2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 13

WebKitCSSKeyframeRule Class Reference

Page 63: Safari JS reference

Inherits from CSSRule

Availability Available in Safari 4.0 and later.Available in iOS 2.0 and later.

Companion guide Safari CSS Visual Effects Guide

Overview

WebKitCSSKeyframesRule objects represent the keyframes for a single animation, that is, the contents ofan @-webkit-keyframes CSS rule used in animations. The WebKitAnimationEvent class encapsulateinformation about running animations.

Tasks

Accessing Properties

name (page 64)The name of the target animation that is set using the -webkit-animation-name property.

cssRules (page 64)The set of style rules that define the keyframes following the animation name.

Changing Rules

insertRule (page 65)Adds a keyframe rule to the collection of keyframes.

deleteRule (page 64)Removes a keyframe rule from the collection of keyframes.

findRule (page 64)Returns the keyframe rule for the specified selector.

Overview 632010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 14

WebKitCSSKeyframesRule Class Reference

Page 64: Safari JS reference

Properties

cssRulesThe set of style rules that define the keyframes following the animation name.

readonly attribute CSSRuleList cssRules;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.0 and later.

nameThe name of the target animation that is set using the -webkit-animation-name property.

attribute DOMString name;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.0 and later.

Methods

deleteRuleRemoves a keyframe rule from the collection of keyframes.

void deleteRule(in DOMString key);

Parameterskey

A selector for the rule that is either a percentage or the keyword from or to.

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.0 and later.

findRuleReturns the keyframe rule for the specified selector.

WebKitCSSKeyframeRule findRule(in DOMString key);

Parameterskey

A selector for the rule that is either a percentage or the keyword from or to.

64 Properties2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 14

WebKitCSSKeyframesRule Class Reference

Page 65: Safari JS reference

Return ValueReturns the keyframe rule corresponding to the given selector if it exists.

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.0 and later.

insertRuleAdds a keyframe rule to the collection of keyframes.

void insertRule(in DOMString rule);

Parametersrule

A string representing a selector and keyframe, where the selector is a percentage or keyword and thekeyframe is a block. The string must follow the format for keyframe blocks in the @-webkit-keyframesCSS rule.

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.0 and later.

Methods 652010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 14

WebKitCSSKeyframesRule Class Reference

Page 66: Safari JS reference

66 Methods2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 14

WebKitCSSKeyframesRule Class Reference

Page 67: Safari JS reference

Availability Available in Safari 4.0 and later.Available in iOS 2.0 and later.

Companion guide Safari CSS Visual Effects Guide

Overview

WebKitCSSMatrix objects represent a 4x4 homogeneous matrix for 3D transforms or a vector for 2Dtransforms. You can use these objects to manipulate matrices in JavaScript. For example, you can multiply,translate, and scale matrices.

The values of a 3D matrix can be initialized from the matrix3d transform function returned bywindow.getComputedStyle(element).webkitTransform(). To apply the final matrix to an element,construct a string using the matrix3d transform function passing the 16 values, and assign it toelement.style.webkitTransform. Similarly, you can construct a matrix for 2D transforms by setting 6values, represented by the a-f properties.

Tasks

Accessing Properties

a (page 69)The first 2D vector value.

b (page 69)The second 2D vector value.

c (page 69)The third 2D vector value.

d (page 70)The fourth 2D vector value.

e (page 70)The fifth 2D vector value.

f (page 70)The sixth 2D vector value.

m11 (page 70)The 3D matrix value in the first row and first column.

Overview 672010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 15

WebKitCSSMatrix Class Reference

Page 68: Safari JS reference

m12 (page 70)The 3D matrix value in the first row and second column.

m13 (page 71)The 3D matrix value in the first row and third column.

m14 (page 71)The 3D matrix value in the first row and fourth column.

m21 (page 71)The 3D matrix value in the second row and first column.

m22 (page 72)The 3D matrix value in the second row and second column.

m23 (page 72)The 3D matrix value in the second row and third column.

m24 (page 72)The 3D matrix value in the second row and fourth column.

m31 (page 72)The 3D matrix value in the third row and first column.

m32 (page 73)The 3D matrix value in the third row and second column.

m33 (page 73)The 3D matrix value in the third row and third column.

m34 (page 73)The 3D matrix value in the third row and fourth column.

m41 (page 73)The 3D matrix value in the fourth row and first column.

m42 (page 74)The 3D matrix value in the fourth row and second column.

m43 (page 74)The 3D matrix value in the fourth row and third column.

m44 (page 74)The 3D matrix value in the fourth row and fourth column.

Setting the Matrix

setMatrixValue (page 77)Sets the matrix values using a string representation.

Applying Operations

multiply (page 75)Returns the result of multiplying this matrix by a given matrix that is on the right.

inverse (page 75)Returns the inverse of this matrix.

68 Tasks2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 15

WebKitCSSMatrix Class Reference

Page 69: Safari JS reference

translate (page 77)Returns the result of translating this matrix by a given vector.

scale (page 76)Returns the result of scaling this matrix by a given vector.

rotate (page 75)Returns the result of rotating this matrix by a given vector.

rotateAxisAngle (page 76)Returns the result of rotating this matrix by a given vector and angle.

Converting the Matrix

toString (page 77)Returns a string representation of the matrix.

Properties

aThe first 2D vector value.

attribute float a;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 3.0 and later.

bThe second 2D vector value.

attribute float b;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 3.0 and later.

cThe third 2D vector value.

attribute float c;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 3.0 and later.

Properties 692010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 15

WebKitCSSMatrix Class Reference

Page 70: Safari JS reference

dThe fourth 2D vector value.

attribute float d;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 3.0 and later.

eThe fifth 2D vector value.

attribute float e;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 3.0 and later.

fThe sixth 2D vector value.

attribute float f;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 3.0 and later.

m11The 3D matrix value in the first row and first column.

attribute float m11;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in Safari 4.0.3 and later.Available in iOS 2.0 and later.

m12The 3D matrix value in the first row and second column.

70 Properties2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 15

WebKitCSSMatrix Class Reference

Page 71: Safari JS reference

attribute float m12;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in Safari 4.0.3 and later.Available in iOS 2.0 and later.

m13The 3D matrix value in the first row and third column.

attribute float m13;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in Safari 4.0.3 and later.Available in iOS 2.0 and later.

m14The 3D matrix value in the first row and fourth column.

attribute float m14;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in Safari 4.0.3 and later.Available in iOS 2.0 and later.

m21The 3D matrix value in the second row and first column.

attribute float m21;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in Safari 4.0.3 and later.Available in iOS 2.0 and later.

Properties 712010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 15

WebKitCSSMatrix Class Reference

Page 72: Safari JS reference

m22The 3D matrix value in the second row and second column.

attribute float m22;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in Safari 4.0.3 and later.Available in iOS 2.0 and later.

m23The 3D matrix value in the second row and third column.

attribute float m23;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in Safari 4.0.3 and later.Available in iOS 2.0 and later.

m24The 3D matrix value in the second row and fourth column.

attribute float m24;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in Safari 4.0.3 and later.Available in iOS 2.0 and later.

m31The 3D matrix value in the third row and first column.

attribute float m31;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

72 Properties2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 15

WebKitCSSMatrix Class Reference

Page 73: Safari JS reference

AvailabilityAvailable in Safari 4.0.3 and later.Available in iOS 2.0 and later.

m32The 3D matrix value in the third row and second column.

attribute float m32;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in Safari 4.0.3 and later.Available in iOS 2.0 and later.

m33The 3D matrix value in the third row and third column.

attribute float m33;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in Safari 4.0.3 and later.Available in iOS 2.0 and later.

m34The 3D matrix value in the third row and fourth column.

attribute float m34;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in Safari 4.0.3 and later.Available in iOS 2.0 and later.

m41The 3D matrix value in the fourth row and first column.

Properties 732010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 15

WebKitCSSMatrix Class Reference

Page 74: Safari JS reference

attribute float m41;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in Safari 4.0.3 and later.Available in iOS 2.0 and later.

m42The 3D matrix value in the fourth row and second column.

attribute float m42;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in Safari 4.0.3 and later.Available in iOS 2.0 and later.

m43The 3D matrix value in the fourth row and third column.

attribute float m43;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in Safari 4.0.3 and later.Available in iOS 2.0 and later.

m44The 3D matrix value in the fourth row and fourth column.

attribute float m44;

DiscussionOne of the 16 values for the 4x4 homogeneous matrix. For example, m12 represents the value in the first rowand the second column.

AvailabilityAvailable in Safari 4.0.3 and later.Available in iOS 2.0 and later.

74 Properties2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 15

WebKitCSSMatrix Class Reference

Page 75: Safari JS reference

Methods

inverseReturns the inverse of this matrix.

WebKitCSSMatrix inverse() raises CSSException;

Return ValueA new matrix that is the inverse of this matrix.

DiscussionThis matrix is not modified by this method.

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.0 and later.

multiplyReturns the result of multiplying this matrix by a given matrix that is on the right.

WebKitCSSMatrix multiply(in WebKitCSSMatrix secondMatrix) raises CSSException;

ParameterssecondMatrix

The matrix to multiply.

Return ValueA new matrix that is the result of multiplying this matrix by the given matrix.

DiscussionThe given matrix is on the right of the multiplication. This matrix is not modified by this method.

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.0 and later.

rotateReturns the result of rotating this matrix by a given vector.

WebKitCSSMatrix rotate(in float rotX, in float rotY, in float rotZ);

ParametersrotX

The x component in the vector, in degrees.

rotYThe y component in the vector, in degrees. If undefined, the x component is used.

Methods 752010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 15

WebKitCSSMatrix Class Reference

Page 76: Safari JS reference

rotZThe z component in the vector, in degrees. If undefined, the x component is used.

Return ValueA new matrix that is the result of rotating this matrix by each of the three rotation matrices about the majoraxes, first the x axes, y axes, and then z axes.

DiscussionThis matrix is not modified by this method.

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.0 and later.

rotateAxisAngleReturns the result of rotating this matrix by a given vector and angle.

WebKitCSSMatrix rotateAxisAngle(in float x, in float y, in float z, in float angle);

Parametersx

The x component in the vector, in degrees.

yThe y component in the vector, in degrees. If undefined, the x component is used.

zThe z component in the vector, in degrees. If undefined, the x component is used.

angleThe angle of rotation about the axis vector, in degrees.

Return ValueA new matrix that is the result of rotating this matrix by each of the three rotation matrices about the majoraxes and angle. The right-hand rule is used to determine the direction of rotation.

DiscussionThis matrix is not modified by this method.

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.0 and later.

scaleReturns the result of scaling this matrix by a given vector.

WebKitCSSMatrix scale(in float scaleX, in float scaleY, in float scaleZ);

ParametersscaleX

The x component in the vector.

scaleYThe y component in the vector. If undefined, the x component is used.

76 Methods2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 15

WebKitCSSMatrix Class Reference

Page 77: Safari JS reference

scaleZThe z component in the vector. If undefined, 1 is used.

Return ValueA new matrix that is the result of scaling this matrix.

DiscussionThis matrix is not modified by this method.

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.0 and later.

setMatrixValueSets the matrix values using a string representation.

void setMatrixValue(in DOMString string);

Parametersstring

A string returned by the matrix3d transform function—typically returned bywindow.getComputedStyle(element).webkitTransform().

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.0 and later.

toStringReturns a string representation of the matrix.

DOMString toString();

Return ValueA string representation of the matrix’s values.

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.0 and later.

translateReturns the result of translating this matrix by a given vector.

WebKitCSSMatrix translate(in float x, in float y, in float z);

Parametersx

The x component in the vector.

yThe y component in the vector.

Methods 772010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 15

WebKitCSSMatrix Class Reference

Page 78: Safari JS reference

zThe z component in the vector. If undefined, 0 is used.

Return ValueA new matrix that is the result of translating this matrix.

DiscussionThis matrix is not modified by this method.

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.0 and later.

78 Methods2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 15

WebKitCSSMatrix Class Reference

Page 79: Safari JS reference

Inherits from CSSValueList

Availability Available in Safari 4.0 and later.Available in iOS 2.0 and later.

Companion guide Safari CSS Visual Effects Guide

Overview

WebKitCSSTransformValue objects represent one transform function in a CSS transform specified usingthe -webkit-transform property. The operationType (page 79) property in this class specifies whichfunction is used. The objects also contain a list of values which are the parameters to the function. Theparameters appear in the same order as they appear in the function.

Tasks

Accessing Properties

operationType (page 79)The transform function used. Possible values are described in CSS_MATRIX (page 80).

Properties

operationTypeThe transform function used. Possible values are described in CSS_MATRIX (page 80).

readonly attribute unsigned short operationType;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.0 and later.

Overview 792010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 16

WebKitCSSTransformValue Class Reference

Page 80: Safari JS reference

Constants

DescriptionConstant

Specifies the matrix transform function.const unsigned short CSS_MATRIX = 1;

Available in Safari 4.0 and later.Available in iOS 2.0 and later.

CSS_MATRIX

Specifies the matrix3d transform function.const unsigned short CSS_MATRIX3D = 2;

Available in Safari 4.0.3 and later.Available in iOS 2.0 and later.

CSS_MATRIX3D

Specifies the perspective transform function.const unsigned short CSS_PERSPECTIVE = 12;

Available in Safari 4.0.3 and later.Available in iOS 2.0 and later.

CSS_PERSPECTIVE

Specifies the rotate transform function.const unsigned short CSS_ROTATE = 3;

Available in Safari 4.0 and later.Available in iOS 2.0 and later.

CSS_ROTATE

Specifies the rotate3d transform function.const unsigned short CSS_ROTATE3D = 4;

Available in Safari 4.0.3 and later.Available in iOS 2.0 and later.

CSS_ROTATE3D

Specifies the rotateX transform function.const unsigned short CSS_ROTATEX = 13;

Available in Safari 4.0.3 and later.Available in iOS 2.0 and later.

CSS_ROTATEX

Specifies the rotateY transform function.const unsigned short CSS_ROTATEY = 14;

Available in Safari 4.0.3 and later.Available in iOS 2.0 and later.

CSS_ROTATEY

80 Constants2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 16

WebKitCSSTransformValue Class Reference

Page 81: Safari JS reference

DescriptionConstant

Specifies the rotateZ transform transform function.const unsigned short CSS_ROTATEZ = 15;

Available in Safari 4.0.3 and later.Available in iOS 2.0 and later.

CSS_ROTATEZ

Specifies the scale transform function.const unsigned short CSS_SCALE = 7;

Available in Safari 4.0 and later.Available in iOS 2.0 and later.

CSS_SCALE

Specifies the scale3d transform function.const unsigned short CSS_SCALE3D = 8;

Available in Safari 4.0.3 and later.Available in iOS 2.0 and later.

CSS_SCALE3D

Specifies the scaleX transform function.const unsigned short CSS_SCALEX = 19;

Available in Safari 4.0 and later.Available in iOS 2.0 and later.

CSS_SCALEX

Specifies the scaleY transform function.const unsigned short CSS_SCALEY = 20;

Available in Safari 4.0 and later.Available in iOS 2.0 and later.

CSS_SCALEY

Specifies the scaleZ transform function.const unsigned short CSS_SCALEZ = 21;

Available in iOS 2.0 and later.

CSS_SCALEZ

Specifies the skew transform function.const unsigned short CSS_SKEW = 8;

Available in Safari 4.0 and later.

CSS_SKEW

Specifies the skewX transform function.const unsigned short CSS_SKEWX = 9;

Available in Safari 4.0 and later.Available in iOS 2.0 and later.

CSS_SKEWX

Constants 812010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 16

WebKitCSSTransformValue Class Reference

Page 82: Safari JS reference

DescriptionConstant

Specifies the skewY transform function.const unsigned short CSS_SKEWY = 10;

Available in Safari 4.0 and later.Available in iOS 2.0 and later.

CSS_SKEWY

Specifies the translate transform function.const unsigned short CSS_TRANSLATE = 5;

Available in Safari 4.0 and later.Available in iOS 2.0 and later.

CSS_TRANSLATE

Specifies the translate3d transform function.const unsigned short CSS_TRANSLATE3D = 6;

Available in Safari 4.0.3 and later.Available in iOS 2.0 and later.

CSS_TRANSLATE3D

Specifies the translateX transform function.const unsigned short CSS_TRANSLATEX = 16;

Available in Safari 4.0 and later.Available in iOS 2.0 and later.

CSS_TRANSLATEX

Specifies the translateY transform function.const unsigned short CSS_TRANSLATEY = 17;

Available in Safari 4.0 and later.Available in iOS 2.0 and later.

CSS_TRANSLATEY

Specifies the translateZ transform function.const unsigned short CSS_TRANSLATEZ = 18;

Available in Safari 4.0.3 and later.Available in iOS 2.0 and later.

CSS_TRANSLATEZ

An unknown function.const unsigned short CSS_UNKNOWN = 0;

Available in Safari 4.0.3 and later.Available in iOS 2.0 and later.

CSS_UNKNOWN

82 Constants2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 16

WebKitCSSTransformValue Class Reference

Page 83: Safari JS reference

Availability Available in iOS 2.0 and later.

Companion guide Safari CSS Visual Effects Guide

Overview

WebKitPoint objects represent a point in two-dimensional space used by CSS transitions specified usingthe -webkit-transition property.

Tasks

Accessing Properties

x (page 83)The x coordinate for the point.

y (page 83)The y coordinate for the point.

Properties

xThe x coordinate for the point.

attribute float x;

AvailabilityAvailable in iOS 2.0 and later.

yThe y coordinate for the point.

Overview 832010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 17

WebKitPoint Class Reference

Page 84: Safari JS reference

attribute float y;

AvailabilityAvailable in iOS 2.0 and later.

84 Properties2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 17

WebKitPoint Class Reference

Page 85: Safari JS reference

Inherits from Event

Availability Available in Safari 4.0 and later.Available in iOS 2.0 and later.

Companion guide Safari CSS Visual Effects Guide

Overview

WebKitTransitionEvent objects provide information about CSS transitions specified using the-webkit-transition property. An event is sent at the end of a transition for each CSS property in thetransition. Each event contains the name of the CSS property and duration of the transition. You can usethese events to perform some action that starts at the end of a transition.

Types of Transition Events

The only possible string value for a transition event’s type property is:

webKitTransitionEndSent when a transition completes.

Tasks

Accessing Properties

propertyName (page 86)The name of the CSS property associated with the transition.

elapsedTime (page 86)The duration of the transition, in seconds, since this event was sent. This value is not affected by thevalue of the CSS -webkit-transition-delay property.

Overview 852010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 18

WebKitTransitionEvent Class Reference

Page 86: Safari JS reference

Initializing

initWebKitTransitionEvent (page 86)Initializes a new transition event object.

Properties

elapsedTimeThe duration of the transition, in seconds, since this event was sent. This value is not affected by the valueof the CSS -webkit-transition-delay property.

readonly attribute double elapsedTime;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.0 and later.

propertyNameThe name of the CSS property associated with the transition.

readonly attribute DOMString propertyName;

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.0 and later.

Methods

initWebKitTransitionEventInitializes a new transition event object.

void initWebKitTransitionEvent(in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in DOMString propertyNameArg, in doubleelapsedTimeArg);

ParameterstypeArg

The type of event.

Possible values for this argument are described in “Types of Transition Events” (page 85). This typeof event can bubble and be canceled. Its propertyName property is always set.

canBubbleArgDetermines whether the event can bubble. Pass true if it can bubble; otherwise, false.

86 Properties2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 18

WebKitTransitionEvent Class Reference

Page 87: Safari JS reference

cancelableArgDetermines whether the event’s default action can be prevented. Pass true if it can be prevented;otherwise, false.

propertyNameArgThe name of the CSS property associated with this event.

elapsedTimeArgThe duration of the transition, in seconds, since the event was sent.

DiscussionYou use this method to initialize the value of a WebKitTransitionEvent object that is created throughthe DocumentEvent interface. This method can only be invoked before the WebKitTransitionEventobject is dispatched via the dispatchEvent method (although, it can be invoked multiple times duringthat phase, if necessary). If it is invoked multiple times, the final invocation takes precedence.

AvailabilityAvailable in Safari 4.0 and later.Available in iOS 2.0 and later.

Methods 872010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 18

WebKitTransitionEvent Class Reference

Page 88: Safari JS reference

88 Methods2010-05-19 | © 2010 Apple Inc. All Rights Reserved.

CHAPTER 18

WebKitTransitionEvent Class Reference

Page 89: Safari JS reference

This table describes the changes to Safari DOM Additions Reference.

NotesDate

Changed title from Safari DOM Extensions Reference.2010-05-19

First revision as a collection document.2010-02-24

Minor edits throughout.2009-08-03

Minor edits throughout.2009-07-28

Added HTML 5 media classes and made other minor edits throughout.2009-06-08

Updated per Safari 4.0 changes.2009-01-30

Added the DOMApplicationCache class.2008-11-21

Changed the title from "Safari DOM Touch Reference for iPhone OS" and addedvisual effects reference.

2008-10-15

Revised document that describes Safari on iPhone-only JavaScript functionsand properties.

2008-07-11

892010-05-19 | © 2010 Apple Inc. All Rights Reserved.

REVISION HISTORY

Document Revision History

Page 90: Safari JS reference

902010-05-19 | © 2010 Apple Inc. All Rights Reserved.

REVISION HISTORY

Document Revision History