This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
John Lee
Posted Apr 06 - Read on Facebook

I'm working on the back of Steve Ruiz's excellent example of using arrays, logic and functions. But extending things more, by:

1. Importing a sketch file and targeting layers to add dynamic content
2. On layer selection, add the selected item to a new array
3. Allow selected items to be only added once, and removed from selection by either array.

BUT I'm stuck, and need some help:
1. how to add only one item (check the array for duplicates)
2. how to then remove the item from either the topping list or selected toppings.

Any help most appreciated!


Radek Kyselý

Maybe if you made the prototype downloadable...

John Lee

checking... give me a minute or two, thanks!

Radek Kyselý

Shouldn't it alert "illegal" or something when you tap pineapple? :D :D

John Lee

why is that?

John Lee ok - good to download now!

John Lee

i used an array, we can update that baby - in a jiffy!

Mike Johnson

Seems way over complicated :)

Mike Johnson

Let me know what you think of this version:

Added a ton of comments, and seems much simpler to me... :)

John Lee

Cool. I'll have a play around to add the ID val, then use that as my comparative source. If you have a simple example using JSON, please share ;)

John Lee

Radek Kyselý Do you think we could use something like this to check the value of the selected Toppings and then create a new layer for each topping?

onlyUnique = (value, index, self) ->
__return self.indexOf(value) === index

selectedTopping = ['cheese', 'ham]
unique = a.filter( onlyUnique )

Steve Ruiz

Here's my shot at it. The logic is handled by having an array of all possible toppings, then an array of only those toppings which are selected, and comparing layers against those arrays - and those arrays against each other - using some handy lodash functions.

Read the entire post on Facebook