Skip to content
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

non-Ajax equivalent of changeContent() method and more. #10

Closed
stanislaw opened this issue Jun 13, 2012 · 4 comments
Closed

non-Ajax equivalent of changeContent() method and more. #10

stanislaw opened this issue Jun 13, 2012 · 4 comments
Assignees

Comments

@stanislaw
Copy link

Hello, Thomas.

Please, consider adding following public methods:

  1. Method "currentScroll" (or currentOffset maybe?) which will return current offset. Without having it, I need to rip it now from .data("scrollWrapper").scrollLeft() (I found you do it this way in a source code).

  2. Method which is Non-AJAX equivalent of changeContent but allowing to just insert(after/before) or replace simple html content. This is how I do it now, ripping more low-level stuff from your source:

$(smooth_div).data('scrollableArea').html(content);

var current_scroll = $(smooth_div).data("scrollWrapper").scrollLeft();

$(smooth_div).smoothDivScroll("recalculateScrollableArea"); 

$(smooth_div).smoothDivScroll('move', current_scroll);

I hope this piece clearly demonstrates the need of the second method.

Maybe, 'currentScroll' method even is not needed, if non-Ajax 'changeContent' will encapsulate preserving of current offset after content change.

Also please see my 'sortable_smooth' branch in my fork of your repo: https://github.com/stanislaw/Smooth-Div-Scroll/tree/sortable_smooth.

See there 'sortable_smooth.html'. It is just your demo index.html with three or four lines added. It is a demonstration of how SmoothDivScroll can play very nice with jQuery Sortable so itt becomes Smooth Sortable Div Scroller. ;)
Maybe you will want somehow adapt it to your examples page.

I found the possibility of this mixture (smooth sortables) very useful in my current project.

That is all!

Thanks for a great work on plugin!

@tkahn
Copy link
Owner

tkahn commented Jul 29, 2012

Hi!

I love the work you are putting in to contribute!
It sounds like a good idea to have a method with which you can add "raw HTML" right into the scroller without using AJAX. I'll also look into the possibilities to access raw data from the plugin with new public methods.

/Thomas

@ghost ghost assigned tkahn Jul 29, 2012
@tkahn
Copy link
Owner

tkahn commented Jul 30, 2012

I'm looking over the code right now and I think the function for adding or replacing content (changeContent) will become bloated and complicated to understand and use if I just keep adding new functionality to it, especially since I want to add a filtering option to the AJAX content loader. Therefore I'm now working on a solution where I split it into three different methods, each with a specific purpose:


getFlickrContent
Arguments are:
flickrFeedURL - a valid URL to a Flickr feed - string
manipulationMethod - add or replace (default) - string
addWhere - first or last (default) - string


getAjaxContent
Arguments are:
ajaxContentURL - a valid URL to an AJAX content source - string
manipulationMethod - add or replace (default) - string
addWhere - first or last (default) - string
filterTag - a jQuery selector that matches the elements from the AJAX content source that you want, for example ".myClass" or "#thisDiv" or "div" - string


getHtmlContent
Arguments are:
htmlContent - any raw HTML that you want - string
manipulationMethod - add or replace (default) - string
addWhere - first or last (default) - string


I know this means that people will have to look over their code if they want to upgrade, but in the long run I think it's worth it.

/Thomas

@stanislaw
Copy link
Author

Sorry with the delay.

These are good points! Let me know, when you merge this!

@tkahn
Copy link
Owner

tkahn commented Sep 12, 2012

Implemented in release 1.3!

@tkahn tkahn closed this as completed Sep 12, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants