-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FileProvider #705
FileProvider #705
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Early feedback:
I'm pretty against the change in View.js
, as it is the role of application developer to build their own dnd logic.
That being said, as we are splitting providers in providers + parsers, I think it's a good idea to have a File provider. This provider would have more or less what is in the current drop listener in its preprocessDataLayer
method, I guess.
This would let the user deals with their File objects as they see fit, so be more flexible: you can get File
instances by other means that drag&drop and we would support this too.
Fundamentally, we should not forget that iTowns is a framework not an app. We must help user build their own app, but let them make their own choices.
src/Core/View.js
Outdated
const prevDefault = e => e.preventDefault(); | ||
viewerDiv.addEventListener('dragenter', prevDefault, false); | ||
viewerDiv.addEventListener('dragover', prevDefault, false); | ||
viewerDiv.addEventListener('dragleave', prevDefault, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember that iTowns is a framework, not an app. It is made to build other app that can have vastly different requirements. So you cannot call preventDefault on these events by default.
I even think a drop
listener has nothing to do in iTowns. The way user gets files is implementation dependant. Also, they might use a dnd lib for instance.
I agree that it should not be hardcoded this way in the view. |
What if they don't want drag & drop? What if they want to use draggable.js or interact.js (because they already use it in their application elsewhere)? What if they want to do something completely different with drag&drop? What if? You need to shift your focus from the (very nice, but all more or less the same) demos we have seen during the code sprint to real-life application, integrated into bigger websites, with vastly different use cases and requirements. Therefore, we need to start from the common point. |
As I said, I agree, putting the code in View was to give a quick working draft. dnd helper code should definitely be opt in and go in a separate file (not even in the bundle). My personal use case is not production of big websites, it is demos, proofs of concept, research and education. So ease of use is paramount. I do not know anything about draggalbe.js or interact.js and I do not want to!. I do not want any of my students either (unless they really want/have to) ! That being said, taking your concerns into account, I have just updated the PR to use a new FileProvider and move the addEventListeners to the examples/filedrop.html . |
837276e
to
7e6b871
Compare
@autra what do you think of it now ? |
Very cool to do this ! It is really enjoyable to drop files like this, it has potential for a more complete example, with 3D object positioning and such ! Could you be more detailed in the example (in term of UI) on what to do and which type of file is supported ? |
@mbredif could you extract the file registry part to its own PR please? It needs to be worked on in itself, as there is a bit more work associated with it to be done. Thanks! |
This PR may be split into 5 atomic parts (with no file overlap) :
To actually do something, you need 1234 or 1235. What do you have in mind? |
Imho you should move all the things except the file drop example into the new PR (that would be 1245) |
We may not want exactly a For instance, the first step to turning the hardcoded logic of the |
With PR #798, your file would be represented by a const layer = {
id,
type,
source: { // describe your source
protocol: 'file'
url: './folder/file.geojson'
}
convert, // function to convert your file
} |
indeed, I'll close this when the functionality will be available. |
We got |
This PR falls under the umbrella of #695 of refactoring providers, parsers and symbolizers.
It is based on the parser registry and will be rebased once #723 is merged.
file
layer :option.crs
parameter for the desired crs.object3d
key, then it uses thelayer.convert
mechanism (cf WFSProvider) to get one.object3d
to the layer (with code to get picking right)This FileProvider enables the drag'n'drop use case #702 to be implemented rather simply as a new example.
Version 2
Version 1