Class: SC.CollectionView
Extends
SC.CollectionContent, SC.CollectionViewDelegate, SC.View.
This class renders a collection of views based on the items array set
as its content. You will not use this class directly as it does not
order the views in any manner. Instead you will want to subclass
SC.CollectionView
or use one of its existing subclasses in SproutCore
such as SC.ListView
, which renders items in a vertical list or SC.GridView
,
which renders items in a grid.
To use a CollectionView subclass, just create the view and set the 'content'
property to an array of objects. The collection view will create instances of
the given exampleView
class for each item in the array. You can also bind to
the selection property if you want to monitor the current selection.
Extreme Performance
SC.CollectionView
does not just naively render one view per item and
instead is aggressively optimized to allow for collections of
hundreds of thousands of items to perform as fast as only a few items. In
order to achieve this, first it only creates views and elements for the items
currently visible. Therefore, when overriding SC.CollectionView
, it is
critically important to implement contentIndexesInRect
which should return
only the indexes of those items that should appear within the visible rect.
By returning only the indexes that are visible, SC.CollectionView
can represent
enormous collections with only a few views and elements.
The second optimization, is that SC.CollectionView
will pool and reuse the
few views and elements that it does need to create. Creating and destroying
views incrementally hurts performance, so by reusing the same views over and
over, the view can much more quickly alter the set of visible views. As well,
inserting and removing elements from the DOM takes more time than simply
modifying the contents of the same elements over and over, which allows us to
leave the DOM tree untouched.
Defined in: collection.js
- Since:
- SproutCore 0.9
Field Summary
- acceptsFirstResponder
- action
- ACTION_DELAY
- actOnSelect
- allContentIndexes
- calculatedHeight Deprecated
- calculatedWidth Deprecated
- canDeleteContent
- canEditContent
- canReorderContent
- classNames
- content
- contentDelegate
- contentExampleViewKey
- contentGroupExampleViewKey
- contentValueKey
- delegate
- displayProperties
- dragContent
- dragDataTypes
- exampleView
- groupExampleView
- isActive
- isDropTarget
- isEditable
- isEnabled
- isSelectable
- length
- nowShowing
- proposedDropOperation
- proposedInsertionIndex
- renderDelegateName
- reorderDataType
- rightIconAction
- rightIconTarget
- selection
- selectionDelegate
- selectOnMouseDown
- target
- useFastPath Deprecated
- useToggleSelection
- Fields borrowed from SC.View:
- acceptsMultitouch, ariaHidden, ariaRole, attributeBindings, autoMixins, backgroundColor, childViewLayout, childViewLayoutOptions, childViews, childViewsNeedLayout, classNameBindings, concatenatedProperties, createdByParent, designMode, enabledState, firstKeyView, hasLayout, hasTouch, hasVisibility, isBuildingIn, isBuildingOut, isChildViewLayoutLive, isFixedHeight, isFixedPosition, isFixedSize, isFixedWidth, isKeyResponder, isTextSelectable, isView, isVisible, lastKeyView, layerLocationNeedsUpdate, layerNeedsUpdate, layout, modeAdjust, nextKeyView, page, pane, parentView, previousKeyView, shouldInheritCursor, shouldInheritEnabled, tagName, themeName, toolTip, touchBoundary, transitionAdjust, transitionAdjustOptions, transitionHide, transitionHideOptions, transitionIn, transitionInOptions, transitionOut, transitionOutOptions, transitionShow, transitionShowOptions, useStaticLayout
- Fields borrowed from SC.Responder:
- hasFirstResponder, isFirstResponder, responderContext
- Fields borrowed from SC.Object:
- isDestroyed, isObject, nextProperty, object, property, toInvalidate
- Fields borrowed from SC.Observable:
- isObservable
Instance Methods
- acceptDragOperation(drag, op)
- adjustLayout()
- collapse(indexes)
- collectionViewShouldBeginDrag(view)
- collectionViewShouldSelectItem(view, item)
- computeDragOperations(drag, evt)
- computeLayout()
- computeNowShowing(clippingFrame)
- contentIndexesInRect(rect)
- contentIndexForLayerId(id)
- contentLengthDidChange()
- contentPropertyDidChange(target, key, indexes)
- contentRangeDidChange(content, object, key, indexes)
- createItemView(exampleClass, idx, attrs)
- deleteSelection()
- deselect(indexes)
- doubleClick(ev)
- dragDataForType(drag, dataType)
- dragEnded()
- dragUpdated(drag, evt)
- expand(indexes)
- hideInsertionPoint()
- insertBacktab(evt)
- insertionIndexForLocation(loc, dropOperation)
- insertTab(evt)
- itemViewForContentIndex(idx, rebuild)
- itemViewForContentObject(object)
- itemViewForEvent(evt)
- layerIdFor(idx)
- layoutForContentIndex(contentIndex)
- performDragOperation(drag, op)
- reload(indexes)
- reloadIfNeeded()
- reloadSelectionIndexes(indexes)
- reloadSelectionIndexesIfNeeded()
- removeContentRangeObserver()
- scrollToContentIndex(contentIndex)
- scrollToItemView(view)
- select(indexes, extend)
- selectNextItem(extend, numberOfItems)
- selectPreviousItem(extend, numberOfItems)
- showInsertionPoint(itemView, dropOperation)
- updateContentRangeObserver()
Field Detail
acceptsFirstResponder Boolean- Default value:
- NO
Invoked when the user double clicks on an item (or single clicks of
actOnSelect
is true)
Set this to the name of the action you want to send down the
responder chain when the user double clicks on an item (or single clicks
if actOnSelect
is true). You can optionally specify a specific target as
well using the target property.
If you do not specify an action, then the collection view will also try to invoke the action named on the target item view.
- Default value:
- null
- See:
- SC.ActionSupport
- Default value:
- 200
Trigger the action method on a single click.
Normally, clicking on an item view in a collection will select the content object and double clicking will trigger the action method on the collection view.
If you set this property to YES
, then clicking on a view will both select
it (if isSelected
is true) and trigger the action method.
Use this if you are using the collection view as a menu of items.
- Default value:
- NO
This computed property returns an index set selecting all content indexes. It will recompute anytime the length of the collection view changes.
This is used by the default contentIndexesInRect()
implementation.
- Default value:
- 0
- Default value:
- 0
Allow the user to delete items using the delete key
If true the user will be allowed to delete selected items using the delete key. Otherwise deletes will not be permitted.
When canDeleteContent
is true, item views will have the isDeletable
property set to true (if the isEditable
is true on the collection).
- Default value:
- NO
Allow user to edit the content by double clicking on it or hitting return.
This will only work if isEditable
is YES
and the item view implements
the beginEditing()
method.
When canEditContent
is true, item views will have the isEditable
property set to true (if the isEditable
is true on the collection).
Allow user to reorder items using drag and drop.
If true, the user can use drag and drop to reorder items in the list. If you also accept drops, this will allow the user to drop items into specific points in the list. Otherwise items will be added to the end.
When canReorderContent
is true, item views will have the isReorderable
property set to true (if the isEditable
is true on the collection).
- Default value:
- NO
- Default value:
- ['sc-collection-view']
- See:
- SC.View#classNames
An array of content objects
This array should contain the content objects you want the collection view
to display. An item view (based on the exampleView
view class) will be
created for each content object, in the order the content objects appear
in this array.
If you make the collection editable, the collection view will also modify
this array using the observable array methods of SC.Array
.
Usually you will want to bind this property to a controller property that actually contains the array of objects you to display.
- Default value:
- null
The delegate responsible for providing additional display information about the content. If you bind a collection view to a controller, this the content will usually also be the content delegate, though you could implement your own delegate if you prefer.
If set, this key will be used to get the example view for a given
content object. The exampleView
property will be ignored.
- Default value:
- null
If set, this key will be used to get the example view for a given
content object. The groupExampleView
property will be ignored.
- Default value:
- null
Property on content items to use for display.
Built-in item views such as the LabelView
s and ImageView
s will use the
value of this property as a key on the content object to determine the
value they should display.
For example, if you set contentValueKey
to 'name' and set the
exampleView
to an SC.LabelView
, then the label views created by the
collection view will display the value of the content.name.
If you are writing your own custom item view for a collection, you can
get this behavior automatically by including the SC.Control
mixin on your
view. You can also ignore this property if you like. The collection view
itself does not use this property to impact rendering.
- Default value:
- null
Delegate used to implement fine-grained control over collection view behaviors.
You can assign a delegate object to this property that will be consulted
for various decisions regarding drag and drop, selection behavior, and
even rendering. The object you place here must implement some or all of
the SC.CollectionViewDelegate
mixin.
If you do not supply a delegate but the content object you set implements
the SC.CollectionViewDelegate
mixin, then the content will be
automatically set as the delegate. Usually you will work with a
CollectionView
in this way rather than setting a delegate explicitly.
- Default value:
- null
- Default value:
- ['isActive']
This property is set to the IndexSet of content objects that are the subject of a drag whenever a drag is initiated on the collection view. You can consult this property when implementing your collection view delegate methods, but otherwise you should not use this property in your code.
- Default value:
- null
Implements the drag data source protocol for the collection view. This
property will consult the collection view delegate if one is provided. It
will also do the right thing if you have set canReorderContent
to YES
.
The view class to use when creating new item views.
The collection view will automatically create an instance of the view class you set here for each item in its content array. You should provide your own subclass for this property to display the type of content you want.
The view you set here should understand the following properties, which it can use to alter its display:
content
-- The content object from the content array your view should display.isEnabled
-- False if the view should appear disabled.isSelected
-- True if the view should appear selected.contentIndex
-- The current index of the view's content.isEditable
-- True if the view should appear editable by clicking on it or hitting the Return key.isReorderable
-- True if the view should appear reorderable by dragging it.isDeletable
-- True if the view should appear deletable, by clicking on a delete button within it or hitting the Delete key.
Working with View and Element Pooling
As noted in the SC.CollectionView
description above, by default the few
instances that are needed of the exampleView
class will be created and then
reused. Reusing an exampleView
means that the content, isSelected
, isEnabled
,
isEditable
, isReorderable
, isDeletable
and contentIndex
properties will be
updated as an existing view is pulled from the pool to be displayed.
If your custom exampleView
class has trouble being reused, you may want to
implement the sleepInPool
and awakeFromPool
methods in your exampleView
.
These two methods will be called on the view, one before it is pooled,
sleepInPool
, and the other before it is unpooled, awakeFromPool
. For
example, if your item views have images and there is a delay for new
images to appear, you may want to use sleepInPool
to ensure the previous
image is unloaded so it doesn't appear momentarily while the new image loads.
Also, if the rendered output of your exampleView
does not update properly you
can disable reuse of the layer by setting isLayerReusable
to false. This
will reduce the performance of your collection though and it is recommended
that you instead look at ways to properly update the existing layer as the
content changes.
Finally, if you really don't want view or element reuse at all, you may
disable them both by setting isReusable
to false in your exampleView
class.
Your collection will still benefit greatly from incremental rendering, but
it will perform slightly less well than with optimal re-use.
Event handling
In general you do not want your child views to actually respond to mouse and keyboard events themselves. It is better to let the collection view do that.
If you do implement your own event handlers such as mouseDown
or mouseUp
,
you should be sure to actually call the same method on the collection view
to give it the chance to perform its own selection housekeeping.
- Default value:
- SC.View
The view class to use when creating new group item views.
The collection view will automatically create an instance of the view class you set here for each item in its content array. You should provide your own subclass for this property to display the type of content you want.
If you leave this set to null then the regular example view will be used
with the isGroupView
property set to YES
on the item view.
- Default value:
- null
Changing this property value by default will cause the CollectionView
to
add/remove an 'active' class name to the root element.
- Default value:
- NO
Accept drops for data other than reordering.
Setting this property to return true when the view is instantiated will cause it to be registered as a drop target, activating the other drop machinery.
- Default value:
- NO
Allow user to edit content views.
Whenever isEditable
is false, the user will not be able to reorder, add,
or delete items regardless of the canReorderContent
and canDeleteContent
and isDropTarget
properties.
- Default value:
- YES
Enable or disable the view.
The collection view will set the isEnabled
property of its item views to
reflect the same view of this property. Whenever isEnabled
is false,
the collection view will also be not selectable or editable, regardless of
the settings for isEditable
& isSelectable
.
- Default value:
- YES
Allow user to select content using the mouse and keyboard.
Set this property to NO
to disallow the user from selecting items. If you
have items in your selectedIndexes
property, they will still be reflected
visually.
- Default value:
- YES
- Default value:
- 0
The set of indexes that are currently tracked by the collection view. This property is used to determine the range of items the collection view should monitor for changes.
The default implementation of this property returns an index set covering the entire range of the content. It changes automatically whenever the length changes.
Note that the returned index set for this property will always be frozen.
To change the nowShowing
index set, you must create a new index set and
apply it.
This property is set to the proposed drop operation during a call to
collectionViewValidateDragOperation
(). Your delegate implementations can
change the value of this property to enforce a different type of drop
operation.
- Default value:
- null
This property is set to the proposed insertion index during a call to
collectionViewValidateDragOperation
(). Your delegate implementations can
change the value of this property to enforce a drop some in some other
location.
- Default value:
- null
- Default value:
- 'collectionRenderDelegate'
When reordering its content, the collection view will store its reorder data using this special data type. The data type is unique to each collection view instance. You can use this data type to detect reorders if necessary.
Invoked when the user single clicks on the right icon of an item.
Set this to the name of the action you want to send down the
responder chain when the user single clicks on the right icon of an item
You can optionally specify a specific target as
well using the rightIconTarget
property.
- Default value:
- null
Optional target to send the action to when the user clicks on the right icon of an item.
If you set the rightIconAction
property to the name of an action, you can
optionally specify the target object you want the action to be sent to.
This can be either an actual object or a property path that will resolve
to an object at the time that the action is invoked.
- Default value:
- null
Indexes of selected content objects. This SC.SelectionSet
is modified
automatically by the collection view when the user changes the selection
on the collection.
Any item views representing content objects in this set will have their
isSelected
property set to YES
automatically.
- Default value:
- null
The delegate responsible for handling selection changes. This property
will be either the delegate, content, or the collection view itself,
whichever implements the SC.CollectionViewDelegate
mixin.
Select an item immediately on mouse down
Normally as soon as you begin a click the item will be selected.
In some UI scenarios, you might want to prevent selection until the mouse is released, so you can perform, for instance, a drag operation without actually selecting the target item.
- Default value:
- YES
Optional target to send the action to when the user double clicks.
If you set the action property to the name of an action, you can optionally specify the target object you want the action to be sent to. This can be either an actual object or a property path that will resolve to an object at the time that the action is invoked.
- Default value:
- null
If YES
, uses the experimental fast CollectionView
path.
Note* The performance improvements in the experimental code have been
integrated directly into SC.CollectionView.
If you have set this property
to true, you should set it to false and refer to the class documentation
explaining how to modify the performance boost behavior if necessary.
Generally, no modifications should be necessary and you should see an immediate performance improvement in all collections, especially on mobile devices.
- Default value:
- NO
Use toggle selection instead of normal click behavior.
If set to true, then selection will use a toggle instead of the normal click behavior. Command modifiers will be ignored and instead clicking once will select an item and clicking on it again will deselect it.
- Default value:
- NO
Instance Method Detail
- Parameters:
- drag
- op
- Returns:
- Boolean
- YES
Adjusts the layout of the view according to the computed layout. Call this method to apply the computed layout to the view.
Collapses any items in the passed selection array that have a disclosure state.
- Parameters:
- indexes SC.IndexSet
- the indexes to expand
- Returns:
- SC.CollectionView
- receiver
Default delegate method implementation, returns YES
if canReorderContent
is also true.
- Parameters:
- view SC.View
Default delegate method implementation, returns YES
if isSelectable
is also true.
- Parameters:
- view
- item
Implements the SC.DropTargetProtocol
interface. The default implementation will
consult the collection view delegate, if you implement those methods.
This method is called once when the drag enters the view area. It's
return value will be stored on the drag object as allowedDragOperations
,
possibly further constrained by the drag source.
Override to return the computed layout dimensions of the collection view. You can omit any dimensions you don't care about setting in your computed value.
This layout is automatically applied whenever the content changes.
If you don't care about computing the layout at all, you can return null.
- Returns:
- Hash
- layout properties
Compute the nowShowing
index set. The default implementation simply
returns the full range. Override to implement incremental rendering.
You should not normally call this method yourself. Instead get the
nowShowing
property.
- Parameters:
- clippingFrame
- Returns:
- SC.IndexSet
- new now showing range
Override to return an IndexSet with the indexes that are at least
partially visible in the passed rectangle. This method is used by the
default implementation of computeNowShowing()
to determine the new
nowShowing
range after a scroll.
Override this method to implement incremental rendering.
- Parameters:
- rect Rect
- the visible rect
- Returns:
- SC.IndexSet
- now showing indexes
Extracts the content index from the passed layerId
. If the layer id does
not belong to the receiver or if no value could be extracted, returns NO
.
- Parameters:
- id String
- the layer id
Called whenever the content length changes. This will invalidate the
length property of the view itself causing the nowShowing
to recompute
which will in turn update the UI accordingly.
- Returns:
- void
Called whenever a property on an item in the content array changes. This
is only called if you have set observesContentProperties
to YES
.
Override this property if you want to do some custom work whenever a property on a content object changes.
The default implementation does nothing.
- Parameters:
- target Object
- the object that changed
- key String
- the property that changed value
- indexes SC.IndexSet
- the indexes in the content array affected
- Returns:
- void
Called whenever the content array or an item in the content array or a
property on an item in the content array changes. Reloads the appropriate
item view when the content array itself changes or calls
contentPropertyDidChange()
if a property changes.
Normally you will not call this method directly though you may override it if you need to change the way changes to observed ranges are handled.
- Parameters:
- content SC.Array
- the content array generating the change
- object Object
- the changed object
- key String
- the changed property or '[]' or an array change
- indexes SC.IndexSet
- affected indexes or null for all items
- Returns:
- void
Primitive to instantiate an item view. You will be passed the class and a content index. You can override this method to perform any other one time setup.
Note that item views may be created somewhat frequently so keep this fast. IMPORTANT:* The attrs hash passed is reused each time this method is called. If you add properties to this hash be sure to delete them before returning from this method.
- Parameters:
- exampleClass Class
- example view class
- idx Number
- the content index
- attrs Hash
- expected attributes
- Returns:
- SC.View
- item view instance
Deletes the selected content if canDeleteContent
is YES
. This will invoke
delegate methods to provide fine-grained control. Returns YES if the
deletion was possible, even if none actually occurred.
- Returns:
- Boolean
- YES if deletion is possible.
- Parameters:
- indexes Number|SC.IndexSet
- index or indexes to deselect
- Returns:
- SC.CollectionView
- receiver
- Parameters:
- ev
Implements the drag data source protocol method. The implementation of
this method will consult the collection view delegate if one has been
provided. It also respects the canReorderContent
method.
- Parameters:
- drag
- dataType
Implements the SC.DropTargetProtocol
protocol. Hides any visible insertion
point and clears some cached values.
Implements the SC.DropTargetProtocol
interface. The default implementation will
determine the drop location and then consult the collection view delegate
if you implement those methods. Otherwise it will handle reordering
content on its own.
Expands any items in the passed selection array that have a disclosure state.
- Parameters:
- indexes SC.IndexSet
- the indexes to expand
- Returns:
- SC.CollectionView
- receiver
Override to hide the insertion point when a drag ends.
Called during a drag to hide the insertion point. This will be called when the user exits the view, cancels the drag or completes the drag. It will not be called when the insertion point changes during a drag.
You should expect to receive one or more calls to
showInsertionPointBefore()
during a drag followed by at least one call to
this method at the end. Your method should not raise an error if it is
called more than once.
- Returns:
- void
- Parameters:
- evt
Get the preferred insertion point for the given location, including an insertion preference of before, after or on the named index.
You can implement this method in a subclass if you like to perform a more efficient check. The default implementation will loop through the item views looking for the first view to "switch sides" in the orientation you specify.
This method should return an array with two values. The first value is
the insertion point index and the second value is the drop operation,
which should be one of SC.DROP_BEFORE
, SC.DROP_AFTER
, or SC.DROP_ON.
The preferred drop operation passed in should be used as a hint as to
the type of operation the view would prefer to receive. If the
dropOperation
is SC.DROP_ON
, then you should return a DROP_ON
mode if
possible. Otherwise, you should never return DROP_ON.
For compatibility, you can also return just the insertion index. If you
do this, then the collection view will assume the drop operation is
SC.DROP_BEFORE.
If an insertion is NOT allowed, you should return -1 as the insertion point. In this case, the drop operation will be ignored.
- Parameters:
- loc Point
- the mouse location.
- dropOperation DropOp
- the preferred drop operation.
- Returns:
- Array
- format: [index, op]
- Parameters:
- evt
Returns the item view for the content object at the specified index. Call this method instead of accessing child views directly whenever you need to get the view associated with a content index.
Although this method take two parameters, you should almost always call it with just the content index. The other two parameters are used internally by the CollectionView.
If you need to change the way the collection view manages item views
you can override this method as well. If you just want to change the
default options used when creating item views, override createItemView
()
instead.
Note that if you override this method, then be sure to implement this
method so that it uses a cache to return the same item view for a given
index unless "force" is YES
. In that case, generate a new item view and
replace the old item view in your cache with the new item view.
- Parameters:
- object Object
Find the first content item view for the passed event.
This method will go up the view chain, starting with the view that was the target of the passed event, looking for a child item. This will become the view that is selected by the mouse event.
This method only works for mouseDown
& mouseUp
events. mouseMoved
events
do not have a target.
Generates a layerId
for the passed index and item. Usually the default
implementation is suitable.
- Parameters:
- idx Number
- the content index
- Returns:
- String
- layer id, must be suitable for use in HTML id attribute
Override to compute the layout of the itemView
for the content at the
specified index. This layout will be applied to the view just before it
is rendered.
- Parameters:
- contentIndex Number
- the index of content being rendered by itemView
- Returns:
- Hash
- a view layout
Implements the SC.DropTargetProtocol
protocol. Consults the collection view
delegate to actually perform the operation unless the operation is
reordering content.
- Parameters:
- drag SC.Drag
- The drag to perform the operation on
- op Number
- The drag operation to perform
- Returns:
- Number
- The operation performed
Regenerates the item views for the content items at the specified indexes. If you pass null instead of an index set, regenerates all item views.
This method is called automatically whenever the content array changes in an observable way, but you can call its yourself also if you need to refresh the collection view for some reason.
Note that if the length of the content is shorter than the child views and you call this method, then the child views will be removed no matter what the index.
- Parameters:
- indexes SC.IndexSet
- Returns:
- SC.CollectionView
- receiver
Invoked once per runloop to actually reload any needed item views. You can call this method at any time to actually force the reload to happen immediately if any item views need to be reloaded.
- Returns:
- SC.CollectionView
- receiver
Called whenever the selection changes. The passed index set will contain any affected indexes including those indexes that were previously selected and now should be deselected.
Pass null to reload the selection state for all items.
- Parameters:
- indexes SC.IndexSet
- affected indexes
- Returns:
- SC.CollectionView
- receiver
Reloads the selection state if needed on any dirty indexes. Normally this will run once at the end of the runloop, but you can force the item views to reload their selection immediately by calling this method.
You can also override this method if needed to change the way the
selection is reloaded on item views. The default behavior will simply
find any item views in the nowShowing
range that are affected and
modify them.
- Returns:
- SC.CollectionView
- receiver
Called whever the view needs to invalidate the current content range observer. This is called whenever the content array changes. You will not usually call this method yourself but you may override it if you provide your own range observer behavior.
Note that if you override this method you should probably also override
updateRangeObserver()
to create or update a range observer as needed.
- Returns:
- void
- Parameters:
- contentIndex Number
- The index of the item to scroll to
- Returns:
- SC.CollectionView
- receiver
Scroll to the passed item view. If the item view is not visible on screen this method will not work.
- Parameters:
- view SC.View
- The item view to scroll to
- Returns:
- SC.CollectionView
- receiver
Selection primitive. Selects the passed IndexSet of items, optionally
extending the current selection. If extend is NO
or not passed then this
will replace the selection with the passed value. Otherwise the indexes
will be added to the current selection.
- Parameters:
- indexes Number|SC.IndexSet
- index or indexes to select
- extend
- {Boolean} optionally extend the selection
- Returns:
- SC.CollectionView
- receiver
Select one or more items following the current selection, optionally extending the current selection. Also scrolls to selected item.
Selection does not wrap around.
- Parameters:
- extend Boolean Optional
- If true, the selection will be extended instead of replaced. Defaults to false.
- numberOfItems Integer Optional
- The number of items to be selected. Defaults to 1.
- Returns:
- SC.CollectionView
- receiver
Select one or more items before the current selection, optionally extending the current selection. Also scrolls the selected item into view.
Selection does not wrap around.
- Parameters:
- extend Boolean Optional
- If true, the selection will be extended instead of replaced. Defaults to false.
- numberOfItems Integer Optional
- The number of previous to be selected. Defaults to 1
- Returns:
- SC.CollectionView
- receiver
Override to show the insertion point during a drag.
Called during a drag to show the insertion point. Passed value is the
item view that you should display the insertion point before. If the
passed value is null
, then you should show the insertion point AFTER that
last item view returned by the itemViews
property.
Once this method is called, you are guaranteed to also receive a call to
hideInsertionPoint()
at some point in the future.
The default implementation of this method does nothing.
- Parameters:
- itemView
- {SC.ClassicView} view the insertion point should appear directly before. If null, show insertion point at end.
- dropOperation
- {Number} the drop operation. will be SC.DROP_BEFORE, SC.DROP_AFTER, or SC.DROP_ON
- Returns:
- void
Called whenever the view needs to updates its contentRangeObserver
to
reflect the current nowShowing
index set. You will not usually call this
method yourself but you may override it if you need to provide some
custom range observer behavior.
Note that if you do implement this method, you are expected to maintain the range observer object yourself. If a range observer has not been created yet, this method should create it. If an observer already exists this method should update it.
When you create a new range observer, the observer must eventually call
contentRangeDidChange()
for the collection view to function properly.
If you override this method you probably also need to override
destroyRangeObserver()
to cleanup any existing range observer.
- Returns:
- void