Skip to content
Permalink
Browse files

image caching studio issues

  • Loading branch information...
koenbok committed May 12, 2015
1 parent 3fc11e7 commit 53b28cfb009efced8ecbb47089163b9c1a1ca7d8
Showing with 27 additions and 12 deletions.
  1. +5 −3 framer/Components/PageComponent.coffee
  2. +17 −4 framer/Layer.coffee
  3. +5 −5 framer/Utils.coffee
@@ -153,19 +153,21 @@ class exports.PageComponent extends ScrollComponent
# See if we meet the minimum velocity to scroll to the next page. If not we snap
# to the layer closest to the scroll point.
if Math.max(Math.abs(velocity.x), Math.abs(velocity.y)) < @velocityThreshold
print "velocity"
@snapToPage(@closestPage, true, @animationOptions)
return

# Figure out which direction we are scrolling to and make a sorted list of
# layers on that side, sorted by absolute distance so we can pick the first.
nextPage = @nextPage(@direction, @_currentPage)

# print Math.max(Math.abs(velocity.x), Math.abs(velocity.y))
# print @direction, nextPage

# If not, we scroll to the closest layer that we have available, often the one
# that we are already at.
nextPage ?= @closestPage

print Math.max(Math.abs(velocity.x), Math.abs(velocity.y))
print @direction, nextPage

@snapToPage(nextPage, true, @animationOptions)

_originScrollPoint: ->
@@ -546,14 +546,27 @@ class exports.Layer extends BaseClass
# Optional base image value
# imageUrl = Config.baseUrl + imageUrl

# If the file is local, we want to avoid caching
# if Utils.isLocal() and not (_.startsWith(imageUrl, "http://") or _.startsWith(imageUrl, "https://"))
if Utils.isLocal() and not imageUrl.match(/^https?:\/\//) and @_cacheImage is false

# See if we need to cache the image
shoudUseImageCache = true

# 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.isLocalUrl(imageUrl)
shoudUseImageCache = false

# If this is a locally served prototype over http (like in studio) we skip the cache
else if imageUrl.indexOf("127.0.0.1") != -1 or imageUrl.indexOf("localhost") != -1
shoudUseImageCache = false

if shoudUseImageCache is false
imageUrl += "?nocache=#{NoCacheDateKey}"

# As an optimization, we will only use a loader
# if something is explicitly listening to the load event

if @events?.hasOwnProperty "load" or @events?.hasOwnProperty "error"

loader = new Image()
@@ -683,15 +683,15 @@ Utils.convertPoint = (input, layerA, layerB, context=false) ->
superLayersA = layerA?.superLayers(context) or []
superLayersB = layerB?.superLayers(context) or []

superLayersB.push layerB if layerB
superLayersB.push(layerB) if layerB

for layer in superLayersA
point.x += layer.x - layer.scrollFrame.x
point.y += layer.y - layer.scrollFrame.y
point.x += layer.x #- layer.scrollFrame.x
point.y += layer.y #- layer.scrollFrame.y

for layer in superLayersB
point.x -= layer.x + layer.scrollFrame.x
point.y -= layer.y + layer.scrollFrame.y
point.x -= layer.x #+ layer.scrollFrame.x
point.y -= layer.y #+ layer.scrollFrame.y

return point

0 comments on commit 53b28cf

Please sign in to comment.
You can’t perform that action at this time.