Listen to famous-angular scroll view - famo.us

Is there a way to listen to a famous-angular's fa-scroll-view for scroll events on touch devices?
For example, right out of the famous-angular docs:
<fa-app ng-controller="ScrollCtrl">
<!-- fa-scroll-view receives all events from $scope.myEventHandler, and decides how to handle them -->
<fa-scroll-view fa-pipe-from="myEventHandler">
<fa-view ng-repeat="view in views">
<fa-modifier fa-size="[undefined, 160]">
<!-- All events on fa-surfaces (click, mousewheel) are piped to $scope.myEventHandler -->
<fa-surface fa-background-color="view.color"
fa-pipe-to="myEventHandler">
</fa-surface>
</fa-modifier>
</fa-view>
</fa-scroll-view>
</fa-app>
I can listen to clicks on myEventHandler with
$scope.myEventHandler.on('click', ...)
but not scroll:
$scope.myEventHandler.on('scroll', ...) // doesn't fire
Is this possible?
Thanks.

$famous.find('fa-scroll-view')[0].renderNode.sync.on('start', function(event) { console.log('start'); });
Also has 'update' and 'end' events

Related

In Semantic-UI-React, is there a way to add an x icon to a text input or dropdown that will clear the text when clicked?

I have both a text input and a dropdown that allows additions (both use the Form.xxx version). For both of these, I would like to add an x icon on the right, that when clicked, will either call a handler or will clear the input's value.
Is this possible in semantic-ui-react?
Thank you
I did find a solution, which I will share, but this means I can no longer have my lock icon on the left hand side, because an input can only have one icon.
What I've done is to use an Icon element, and add an onClick handler to that, as follows:
<Input ...
icon={<Icon name='delete' link onClick={this.handleDeleteClick}/>}/>
(Updated)
To clear the field, there is no "semantic-ui-react" shortcut as far as I know.
However, you can do this manually using your component state.
Here would be an example of this:
class ExampleClearField extends Component {
state = {}
handleChange = (e, { name, value }) => this.setState({ [name]: value })
handleClear = () => this.setState({ email: ''})
render() {
const { email } = this.state
return (
<Form.Input iconPosition='left' name="email />
<Icon name='x' link onClick={this.handleClear} />
<input/>
</Form.Input>
)
}
}
** Notice the link, which is needed for Icon to accept onClick.
Also, dont't forget about (you might need to change it's place depending on iconPostion)
As of Semantic UI React 0.83.0, it is possible to do this with Dropdowns using clearable. You cannot add your own event handler to the "x" by using this. Clicking the "x" will simply clear the selected value and call onChange with the new empty value.
Example from their docs:
const DropdownExampleClearable = () => <Dropdown clearable options={options} selection />
See the example output on their docs page here

Flex Change List Item Selected While Mouse Down

I am trying to create a List which behaves like, for example, the Finder Menu on my Mac. In other words if I click on a List Item, keep my mouse down and move up and down the List I want the Selected Item to change.
In my Flex application if I click on my List and then, with the mouse still down, move up and down the List the Selected Item remains the same.
Any advice would be gratefully received.
Thanks
In StackOverflow tradition I am posting a solution to my own problem after working at it more:
I had an ItemRenderer on my List. In the ItemRenderer I declared a variable to hold a reference to the owning List.
private var _parentList:List;
In the 'set data' function I set this variable to the owner List.
override public function set data(value:Object):void {
super.data = value;
// Check to see if the data property is null.
if (value == null)
return;
// If the data property is not null.
// Get a reference to the parent list.
_parentList = this.owner as List;
...
I then added an EventListener to listen for MouseDown events.
// Attach an eventListener to the ItemRenderer.
this.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
...
My onMouseOver handler looks like this.
private function onMouseOver(event:MouseEvent):void {
//trace(data.LocationName);
if (event.buttonDown == true) {
_parentList.selectedIndex = itemIndex;
}
}
So with this in place I can mouse-down on my List and keeping the mouse button depressed move up and down the List with the List Item beneath the cursor always being selected. The final piece to this is to ensure that the List responds to the selectedIndex being set by the ItemRenderer. When the user changes the selectedIndex property by interacting with the control, the control dispatches the change and changing events. When you change the value of the selectedIndex property programmatically, it dispatches the valueCommit event. To ensure I responded to my programmatic changing of the selected list item I added a handler to the valueCommit event.
<s:List
id="locationsList"
dataProvider="{presenter.locations}"
itemRenderer="itemrenderers.locationListItemRenderer"
useVirtualLayout="false"
width="1869.698" height="1869.698"
y="65.151" x="65.151"
borderVisible="true"
borderColor="{presenter.backgroundColour}"
contentBackgroundAlpha="0"
contentBackgroundColor="0xff336c"
labelField="label"
change="presenter.onLocationListChange(event)"
valueCommit="presenter.onLocationListValueCommit(event)">
<s:layout>
<s:BasicLayout />
</s:layout>
</s:List>
So far it seems to work fine. Hope it helps.

In famous-angular, is there access to scrollview.sync.on(event)?

Right now I have a scrollview with fa-pipe-from from the surfaces in it and that works fine, and I've tried a few ways to listen in on the events from the scrollview.
One way was to add a fa-pipe-to to the scrollview
<fa-scroll-view fa-pipe-from="resultsViewHandler" fa-pipe-to="scrollViewHandler">
pointing to event handler
$scope.scrollViewHandler = new EventHandler();
but no events are coming from this handler
$scope.scrollViewHandler.on("start",function( e ){
console.log( e );
}); // is never called
I've seen in another stackoverflow - link - question which suggested a solution that didn't work:
$famous.find('fa-scroll-view')[0].renderNode.sync.on('start', function(event) {
console.log('start');
});
Any suggestions on how to achieve this?
EDIT: Apparently fa-pipe-to is working as expected, but the scrollview isn't emitting all events. The events that do work are: onEdge, offEdge, settle, pageChange and you can use them by piping the scrollview to an empty event handler like described above and listening to these events on it. The events that don't work are: start, update, end, resize and unfortunately are the ones I need the most.
Hey I answered that question in the link
I gave my scrollview an ID
<fa-scroll-view id="footer-scrollview" fa-pipe-from="footerScrollHandler"></fa-scroll-view>
And was able to listen to the events like so:
var scrollView = $famous.find('#footer-scrollview')[0].renderNode,
scrollViewHandler = scrollView.sync
;
scrollViewHandler.on('start', function(event) {
console.log('start');
});
'update' and 'end' events worked too. I also used a 2nd scrollview somewhere else in the app (w/ a different ID) and using the same strategy and it worked fine

Interrupt CSS transition by jquery event click and cancel reversing

.trans{
-webkit-transition:background-position 0.2s;
}
I have nav menu items and added the transition above to each of them.
Also JQuery hover functions as:
$(".menuUL li").mouseover(function () {
$(this).css({'background-position':'center top','color':'white'});});
$(".menuUL li").mouseout(function () {
if(this.id == currentTab)
{$(this).css({'background-position':'center top','color':'white'});}
else
{$(this).css({'background-position':'center bottom','color':'#0196e3'});}});
And click function to chance content:
` $(".menuUL li").click(function(){
$(".menuUL li").not(this).css({'background-position':'center bottom','background-color':'#666666','color':'#0196e3'});
$(this).css({'background-position':'center top','background-color':'#CCCCCC','color':'white'});});
`
The problem is when I click on a menu item and suddenly(in <200ms) leave the element(mouseout) before the transition is completed. Reverse transition occurs and the clicked menu element's background position goes back to the initial position.
I need a code like $(this).endtransition()
Could you help pls?

Pass values to content page from programmatically added masterpage menuitem?

I'm working on a project that uses a master page and content pages. My masterpage a navigation bar:
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
<Items>
<asp:MenuItem NavigateUrl="~/ProjectPage.aspx" Text="Home" />
<asp:MenuItem NavigateUrl="~/ProductBacklog.aspx" Text="Product Backlog"/>
<asp:MenuItem NavigateUrl="~/SprintBacklog.aspx" Text="Sprint Backlog" />
<asp:MenuItem NavigateUrl="~/MeetingPage.aspx" Text="Meetings" />
<asp:MenuItem NavigateUrl="~/Burndown.aspx" Text="Burndown"/>
<asp:MenuItem NavigateUrl="~/About.aspx" Text="About Us"/>
</Items>
</asp:Menu>
On one of my content pages, I dynamically add sub-menu menuitems to my 'Sprint Backlog' menuitem. There is a button, and everytime the user clicks that button, a sub-menuitem is added, so that when the user hovers over 'Sprint Backlog' in the navigation menu, the submenu comes up. I do this by creating a list of menuitems, creating a new menuitem with (shown text, value, navigationURL), adding the menuitem to the list of menuitems, then saving the list to Session:
protected void btSave_Click(object sender, EventArgs e)
{
menuItemList = (List<MenuItem>)Session["menuItemList"];
if (menuItemList == null)
{
menuItemList = new List<MenuItem>();
}
MenuItem menuItem = new MenuItem("Sprint " + sprintNumber, sprintNumber.ToString(), "SprintBacklog.aspx");
menuItemList.Add(menuItem);
Session["menuItemList"] = menuItemList;
}
In the code-behind for my masterpage, I create a list of menuitems, set the value of the instance of the menuitem from Session, and add childitems to the navigationmenu at the appropriate index. The childitem I am adding are the menuitems from the list of menuitems.
List<MenuItem> menuItemList;
protected void Page_Load(object sender, EventArgs e)
{
menuItemList = (List<MenuItem>)Session["menuItemList"];
if (menuItemList != null)
{
foreach (MenuItem menuitem in menuItemList)
{
NavigationMenu.Items[2].ChildItems.Add(menuitem);
}
}
}
I know that I gave these childitems a value when I created them, but my problem is accessing those values when I am loading the SprintBacklog.aspx content page. Whenever a user clicks on one of the childitems, it will always navigate to SprintBacklog.aspx, but the contents of that page should differ according to which child item they clicked. I need a way to know which childitem they clicked, and access that value to populate my content page.
If someone has a better way for me to carry this whole thing out, I am open for suggestions and change. Otherwise, if my setup can work, and there is a way for me to extract the value of the clicked childitem, I'd really like to know that.
I know if I hard-code the childitems in my masterpage, I can easily get the value, but my problem is that I'm creating the submenu childitems dynamically, and I'm not sure how to access it.
Any help would be really appreciated! Thanks!
-Jose
It's been a long time since I asked this question, and I'm not familiar with how masterpages work anymore, but if anyone is experiencing anything similar, I may have a suggestion.
Each menu item I was creating was linking to SprintBacklog.aspx like so:
MenuItem menuItem = new MenuItem("Sprint " + sprintNumber, sprintNumber.ToString(), "SprintBacklog.aspx");
What I should have done was link to SprintBacklog.aspx, but also add a parameter to the request with the sprint ID.
Then the controller which handles the rendering of SprintBacklog.aspx would read the parameter and fetch the appropriate data to render.