0

I'm new to Framer and having an extremely annoying issue I've spent hours trying to solve.

I'm trying to build a statement that changes the opacity property of an object with the name passed through the variable sectionToLoad. I'm able to log the statement perfectly in the console but it won't render. Any help would be much appreciated.

HideSection = (sectionToLoad) ->
PossibleSections = ["layerA", "layerB", "layerC", "layerD"]
for i in [0..PossibleSections.length - 1]
    if PossibleSections[i] != sectionToLoad
        console.log(PossibleSections[i])
        PossibleSections[i].opacity = 1
    else
        console.log(sectionToLoad + ".opacity = 1")
        # WHY DOESN'T THIS WORK?
        sectionToLoad.opacity = 0

HideSection("layerB")

#BUT THIS DOES SOME REASON
# layerB.opacity = 1

Here's my framer file http://share.framerjs.com/9pv42mi6c99n/

Jeremy P. Beasley
  • 679
  • 1
  • 7
  • 22
  • `sectionToLoad` is the *string* `'layerB'`, not the *object* `layerB`. Where do the `layerA` ... `layerD` objects come from? Can you change `PossibleSections` to be a string-to-object map instead of an array of strings? – mu is too short Jun 26 '16 at 00:18

1 Answers1

0

The issue here was that I was using strings instead of objects. Literally the addition of unnecessary quotations.

layerB was the object, "layerB" was the string. Thanks to the above comment for the clue.

This is working code.

HideSection = (sectionToLoad) ->
PossibleSections = [layerA, layerB, layerC, layerD]
for i in [0..PossibleSections.length - 1]
    if PossibleSections[i] != sectionToLoad
        console.log(PossibleSections[i])
        PossibleSections[i].opacity = 1
    else
        console.log(sectionToLoad + ".opacity = 1")
        sectionToLoad.opacity = 0

HideSection(layerC)
Jeremy P. Beasley
  • 679
  • 1
  • 7
  • 22