Skip to content

Commit

Permalink
Fix for image cache
Browse files Browse the repository at this point in the history
Cache is now disabled only for local images (server and file urls). You can optionally force using the cache by using layer. _alwaysUseImageCache.
  • Loading branch information
koenbok committed Jul 17, 2015
1 parent 5c47bd5 commit b34eca1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion framer/Components/DeviceComponent.coffee
Expand Up @@ -261,7 +261,7 @@ class exports.DeviceComponent extends BaseClass
else if not @_deviceImageUrl(@_deviceImageName())
@phone.image = ""
else
@phone._cacheImage = true
@phone._alwaysUseImageCache = true
@phone.image = @_deviceImageUrl(@_deviceImageName())
@phone.width = @_device.deviceImageWidth
@phone.height = @_device.deviceImageHeight
Expand Down
18 changes: 7 additions & 11 deletions framer/Layer.coffee
Expand Up @@ -53,7 +53,7 @@ class exports.Layer extends BaseClass
# Special power setting for 2d rendering path. Only enable this
# if you know what you are doing. See LayerStyle for more info.
@_prefer2d = false
@_cacheImage = true
@_alwaysUseImageCache = false

# We have to create the element before we set the defaults
@_createElement()
Expand Down Expand Up @@ -547,18 +547,12 @@ class exports.Layer extends BaseClass
# imageUrl = Config.baseUrl + imageUrl


# See if we need to cache the image
shoudUseImageCache = true
print imageUrl
print "@_cacheImage", @_cacheImage
print "Utils.isLocalAssetUrl(imageUrl)", Utils.isLocalAssetUrl(imageUrl)

# We can always disable the cache with this property
if @_cacheImage is false
shoudUseImageCache = false

# If this is a file url, we don't use any cache
else if Utils.isLocalAssetUrl(imageUrl)
shoudUseImageCache = false

if shoudUseImageCache is false
if @_alwaysUseImageCache is false and Utils.isLocalAssetUrl(imageUrl)
imageUrl += "?nocache=#{NoCacheDateKey}"

# As an optimization, we will only use a loader
Expand Down Expand Up @@ -769,6 +763,8 @@ class exports.Layer extends BaseClass
exportable: false
get: ->
@_draggable ?= new LayerDraggable(@)
set: (value) ->
@draggable.enabled = value if _.isBoolean(value)

# anchor: ->
# if not @_anchor
Expand Down

0 comments on commit b34eca1

Please sign in to comment.