Comments (5)
Here is my code:
function _createCollectionView() {
this.scrollView = new FlexScrollView({
layout: CollectionLayout,
flow: true,
flowOptions: {
spring: {
dampingRatio: 0.8,
period: 1000
}
},
autoPipeEvents: true,
debug: false,
mouseMove: true,
useContainer: true,
layoutOptions: {
itemSize: [250, 150], // item has width and height
margins: [10, 5, 10, 5], // outer margins
spacing: [10, 10] // spacing between items
},
dataSource: _getDogSurfaces.call(this)
});
return this.scrollView;
}
If I resize the the browser and reload the page only the visible surfaces seem to get the events attached.
Just for illustration a screenshot
There are 24 surfaces in the CollectionView and in the above screenshot only the 16 visible surfaces have the click events attached for edit and delete in the upper right corner of a surface.
Any ideas what I'm missing?
from famous-flex.
Alright thanks for that info.
I think the problem is related to the 'autoPipeEvents' option. You could try not using that, and instead just piping the events from the views to the Scrollview yourself. I'll hopefully have some time this weekend to have a closer look at it.
And, nice screenshot btw :)
cheers, Hein
from famous-flex.
Thanks Hein, wouldn't be possible without your excellent library. It's just too sad that Famous Industries has take famo.us into something private. My hope is that SamsaraJS can be used to replace famous, I don't see any other library that could be a candidate.
Coming back to our problem: Unfortunately, piping each surface directly to the scrollView did result in the same issue. There must be something else causing this behavior.
from famous-flex.
It crossed my mind that the issue could be caused by the template that populates the content for each surface, because I attach the event handlers via jQuery. So I have tried to add the click event on a mouseover event, because all surface are rendered at this time.
function _addClickEventListeners() {
app.wait(500).then(function() {
// add click events to edit and delete buttons to all dog panels
_.each(this.myDogs, function(d, i) {
$('#edit' + i).mouseenter(function() {
console.log('#edit' + i + ' loaded' )
$('#edit' + i).on('click', _.debounce(function() {
require(['modules/updateDogDialog'], function(modal) {
var dialog = new modal(d);
this.modalController.show(new ModalView(dialog));
}.bind(this));
}.bind(this), 300));
}.bind(this))
$('#delete' + i).on('click', _.debounce(function() {
var deleteDog = confirm('Do you really want to remove this dog?');
if ( deleteDog ) {
_removeDog.call(this, i);
}
}.bind(this), 300));
if ( i === this.myDogs.length - 1 ) {
this.scrollView.ensureVisible(i);
}
}.bind(this));
}.bind(this));
}
But still, only the surface visible in browsers viewport get the event handlers attached. When I scroll down further they don't get attached.
from famous-flex.
Right, I see... Your jQuery code attaches its event handlers based on what is in the DOM at that time. ScrollView however, only adds the surfaces to the DOM which are visible and needed for scrolling. When scrolling, surfaces are dynamically added/removed to and from the DOM. That's why the surfaces which are not in the DOM at the time when _addClickEventListeners
is called, don't have event handlers attached.
Personally I would not use this approach to attach event handlers, but instead use the famous event mechanisms instead.
Alternatively you could use the option layoutAll
which causes all surfaces to be added to the DOM always, potentially at the cost of (scrolling) performance.
from famous-flex.
Related Issues (20)
- velocity limit HOT 10
- Scrollview is only partially shown (after blurring an input element, window scroll position isnt reset) HOT 9
- Pull to refresh on desktop HOT 3
- any plans to support https://github.com/Famous/engine/tree/v1.0.0? HOT 7
- Scrollview: scroll without animation HOT 3
- Invalid bower version HOT 2
- FlexScrollView - mousepad two finger scrolling doesn't work in paginated view
- LayoutController insert 0 not working HOT 6
- CollectionLayout last row just partial visible HOT 1
- WheelLayout (DatePicker) sometimes wrong number sequence HOT 7
- Is mixed-mode really good(right) ? HOT 7
- What is the state of Famous-Flex? HOT 6
- Surface leakage issue because of Entity.register HOT 2
- Bug in DatePicker.Component.FullDay HOT 7
- SamsaraJS support
- Error: HOT 6
- Correction in documentation HOT 2
- Use famous-sizeconstraint with FlexScrollView
- Changes to LinkedListViewSequence does not get reflected in FlexScrollView
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from famous-flex.