public override void OnInspectorGUI() { InfiniteScroll scroll = (InfiniteScroll)target; scroll.initOnAwake = EditorGUILayout.Toggle("Init on awake", scroll.initOnAwake); base.OnInspectorGUI(); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); InfiniteScroll scroller = target as InfiniteScroll; Color guiColor = GUI.color; if (!scroller.IsDataOk()) { GUI.color = Color.red; } if (GUILayout.Button("Fetch layout data")) { scroller.FetchData(); if (!Application.isPlaying) { EditorSceneManager.MarkSceneDirty(scroller.gameObject.scene); } } GUI.color = guiColor; }
public void SetupState(InfiniteScroll p, Camera c, int index) { // add a second object if we need one to wrap properly if (RepositionLogic.PositionMode != FreeParallaxPositionMode.IndividualStartOffScreen && RepositionLogic.PositionMode != FreeParallaxPositionMode.IndividualStartOnScreen && GameObjects.Count == 1) { GameObject obj = GameObject.Instantiate(GameObjects[0]) as GameObject; obj.transform.parent = GameObjects[0].transform.parent; obj.transform.position = GameObjects[0].transform.position; GameObjects.Add(obj); } if (GameObjectRenderers.Count == 0) { foreach (GameObject obj in GameObjects) { Renderer r = obj.GetComponent <Renderer>(); if (r == null) { Debug.LogError("Null renderer found at element index " + index.ToString() + ", each game object in the parallax must have a renderer"); return; } GameObjectRenderers.Add(r); } } }
public void InitializeInfiniteScroll(IDataListViewModel viewModel, CoreSwipeRefreshLayout refreshLayout, ListView listView) { this.ExecuteMethod("InitializeInfiniteScroll", delegate() { _infiniteScroller = new Droid.InfiniteScroll(viewModel, refreshLayout, listView); listView.SetOnScrollListener(_infiniteScroller); }); }
public async Task <IActionResult> GetMessages(long friendId, [FromQuery] InfiniteScroll scroll) { if (!await Friendships.CheckIfFriendshipExist(User.Id(), friendId)) { return(NotFound()); } return(Ok(await Chat.GetMessages(scroll, User.Id(), friendId))); }
//SINGLETON INITIALIZATION //====================================================================== void SingletonInit() { if (Instance != null) { Destroy(gameObject); } else { Instance = this; } }
private void Start() { Global.CheckNullValues(gameObject, MenuContacts); ContactController.Instance.FilterContacts(string.Empty, true); InfiniteScroll scroll = GetComponent <InfiniteScroll>(); scroll.OnFill += OnFillItem; scroll.OnHeight += OnHeightItem; scroll.InitData(ContactController.Instance.AllContactsFiltered.Count); }
public void ThenIShouldBeAbleToSeeTheInfiniteScroll() { Assert.IsTrue(InfiniteScroll.isDisplayed()); }
public void WhenIScrollToTheTopOfThePage() { InfiniteScroll.ScrollToTop(); }
public void WhenIScrollToTheBottomOfThePage() { InfiniteScroll.ScrollToBottom(); }
public async Task <IActionResult> GetFriends([FromQuery] InfiniteScroll scroll) { return(Ok(await Chat.GetFriends(scroll, User.Id()))); }
public async Task <IActionResult> GetNotifications([FromQuery] InfiniteScroll scroll) { return(Ok(await Notifications.GetNotifications(scroll, User.Id()))); }
static public void AddScrollView(MenuCommand menuCommand) { GameObject root = CreateUIElementRoot("InfiniteScroll", new Vector2(200, 200)); GameObject viewport = CreateUIObject("Viewport", root); GameObject content = CreateUIObject("Content", viewport); GameObject parent = menuCommand.context as GameObject; if (parent != null) { root.transform.SetParent(parent.transform, false); } Selection.activeGameObject = root; GameObject hScrollbar = CreateScrollbar(); hScrollbar.name = "Scrollbar Horizontal"; hScrollbar.transform.SetParent(root.transform, false); RectTransform hScrollbarRT = hScrollbar.GetComponent <RectTransform>(); hScrollbarRT.anchorMin = Vector2.zero; hScrollbarRT.anchorMax = Vector2.right; hScrollbarRT.pivot = Vector2.zero; hScrollbarRT.sizeDelta = new Vector2(0, hScrollbarRT.sizeDelta.y); GameObject vScrollbar = CreateScrollbar(); vScrollbar.name = "Scrollbar Vertical"; vScrollbar.transform.SetParent(root.transform, false); vScrollbar.GetComponent <Scrollbar>().SetDirection(Scrollbar.Direction.BottomToTop, true); RectTransform vScrollbarRT = vScrollbar.GetComponent <RectTransform>(); vScrollbarRT.anchorMin = Vector2.right; vScrollbarRT.anchorMax = Vector2.one; vScrollbarRT.pivot = Vector2.one; vScrollbarRT.sizeDelta = new Vector2(vScrollbarRT.sizeDelta.x, 0); RectTransform viewportRect = viewport.GetComponent <RectTransform>(); viewportRect.anchorMin = Vector2.zero; viewportRect.anchorMax = Vector2.one; viewportRect.sizeDelta = Vector2.zero; viewportRect.pivot = Vector2.up; RectTransform contentRect = content.GetComponent <RectTransform>(); contentRect.anchorMin = Vector2.up; contentRect.anchorMax = Vector2.one; contentRect.sizeDelta = new Vector2(0, 300); contentRect.pivot = Vector2.up; InfiniteScroll scrollRect = root.AddComponent <InfiniteScroll>(); scrollRect.content = contentRect; scrollRect.viewport = viewportRect; scrollRect.horizontalScrollbar = hScrollbar.GetComponent <Scrollbar>(); scrollRect.verticalScrollbar = vScrollbar.GetComponent <Scrollbar>(); scrollRect.horizontalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport; scrollRect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport; scrollRect.horizontalScrollbarSpacing = -3; scrollRect.verticalScrollbarSpacing = -3; Image rootImage = root.AddComponent <Image>(); rootImage.sprite = AssetDatabase.GetBuiltinExtraResource <Sprite>(bgPath); rootImage.type = Image.Type.Sliced; rootImage.color = panelColor; Mask viewportMask = viewport.AddComponent <Mask>(); viewportMask.showMaskGraphic = false; Image viewportImage = viewport.AddComponent <Image>(); viewportImage.sprite = AssetDatabase.GetBuiltinExtraResource <Sprite>(maskPath); viewportImage.type = Image.Type.Sliced; }
/// <summary> /// Update the element given a distance of parallax move, t /// </summary> /// <param name="p">InfiniteScroll container</param> /// <param name="t">Total amount the parallax moved. Elements will move a percetage of this distance.</param> public void Update(InfiniteScroll p, float t, Camera c) { if (GameObjects == null || GameObjects.Count == 0 || GameObjects.Count != GameObjectRenderers.Count) { // cannot update, something went wrong in setup return; } // move everything first if (p.IsHorizontal) { foreach (GameObject obj in GameObjects) { obj.transform.Translate(t * SpeedRatio, 0.0f, 0.0f); } } else { foreach (GameObject obj in GameObjects) { obj.transform.Translate(0.0f, t * SpeedRatio, 0.0f); } } bool wrap = RepositionLogic.PositionMode != FreeParallaxPositionMode.IndividualStartOffScreen && RepositionLogic.PositionMode != FreeParallaxPositionMode.IndividualStartOnScreen; // if it's an individual object we let it go an extra screen width in case the player changes direction float padding = (wrap ? 0.0f : 1.0f); float minEdge, maxEdge; if (p.IsHorizontal) { minEdge = c.rect.x - padding; maxEdge = c.rect.width + padding; } else { minEdge = c.rect.y - padding; maxEdge = c.rect.height + padding; } int end = GameObjects.Count; // now check for wrapping and stuff going off screen for (int i = 0; i < end; i++) { GameObject obj = GameObjects[i]; Renderer r = GameObjectRenderers[i]; Bounds b = r.bounds; Vector3 screenEdge = (t > 0 ? c.WorldToViewportPoint(b.min) : c.WorldToViewportPoint(b.max)); float screenEdgeValue = (p.IsHorizontal ? screenEdge.x : screenEdge.y); if (wrap) { if (t > 0 && screenEdgeValue >= maxEdge) { if (p.IsHorizontal) { // move to the back of the line at far left float newX = (GameObjectRenderers[0].bounds.min.x - r.bounds.size.x) + p.WrapOverlap; InfiniteScroll.SetPosition(obj, r, newX, r.bounds.min.y); } else { // move to the back of the line at far bottom float newY = (GameObjectRenderers[0].bounds.min.y - r.bounds.size.y) + p.WrapOverlap; InfiniteScroll.SetPosition(obj, r, r.bounds.min.x, newY); } GameObjects.RemoveAt(i); GameObjects.Insert(0, obj); GameObjectRenderers.RemoveAt(i); GameObjectRenderers.Insert(0, r); } else if (t < 0 && screenEdgeValue <= minEdge) { if (p.IsHorizontal) { // move to the front of the line at far right float newX = (GameObjectRenderers[GameObjects.Count - 1].bounds.max.x) - p.WrapOverlap; InfiniteScroll.SetPosition(obj, r, newX, r.bounds.min.y); } else { // move to the front of the line at far top float newY = (GameObjectRenderers[GameObjects.Count - 1].bounds.max.y) - p.WrapOverlap; InfiniteScroll.SetPosition(obj, r, r.bounds.min.x, newY); } GameObjects.RemoveAt(i); GameObjects.Add(obj); GameObjectRenderers.RemoveAt(i--); GameObjectRenderers.Add(r); end--; } } else if (p.IsHorizontal) { if (t > 0 && (screenEdge.y >= c.rect.height || screenEdgeValue >= maxEdge)) { if (RepositionLogicFunction != null) { RepositionLogicFunction(p, this, t, obj, r); } else { Vector3 leftEdge = c.ViewportToWorldPoint(Vector3.zero); float randX = UnityEngine.Random.Range(RepositionLogic.MinXPercent, RepositionLogic.MaxXPercent); float randY = UnityEngine.Random.Range(RepositionLogic.MinYPercent, RepositionLogic.MaxYPercent); Vector3 newWorldPoint = c.ViewportToWorldPoint(new Vector3(randX, randY)); InfiniteScroll.SetPosition(obj, r, leftEdge.x - newWorldPoint.x, newWorldPoint.y); } } else if (t < 0 && (screenEdge.y >= c.rect.height || screenEdge.x < minEdge)) { if (RepositionLogicFunction != null) { RepositionLogicFunction(p, this, t, obj, r); } else { Vector3 rightEdge = c.ViewportToWorldPoint(Vector3.one); float randX = UnityEngine.Random.Range(RepositionLogic.MinXPercent, RepositionLogic.MaxXPercent); float randY = UnityEngine.Random.Range(RepositionLogic.MinYPercent, RepositionLogic.MaxYPercent); Vector3 newWorldPoint = c.ViewportToWorldPoint(new Vector3(randX, randY)); InfiniteScroll.SetPosition(obj, r, rightEdge.x + newWorldPoint.x, newWorldPoint.y); } } } else { if (t > 0 && (screenEdge.x >= c.rect.width || screenEdgeValue >= maxEdge)) { if (RepositionLogicFunction != null) { RepositionLogicFunction(p, this, t, obj, r); } else { Vector3 bottomEdge = c.ViewportToWorldPoint(Vector3.zero); float randX = UnityEngine.Random.Range(RepositionLogic.MinXPercent, RepositionLogic.MaxXPercent); float randY = UnityEngine.Random.Range(RepositionLogic.MinYPercent, RepositionLogic.MaxYPercent); Vector3 newWorldPoint = c.ViewportToWorldPoint(new Vector3(randX, randY)); InfiniteScroll.SetPosition(obj, r, newWorldPoint.x, bottomEdge.y - newWorldPoint.y); } } else if (t < 0 && (screenEdge.x >= c.rect.width || screenEdge.y < minEdge)) { if (RepositionLogicFunction != null) { RepositionLogicFunction(p, this, t, obj, r); } else { Vector3 topEdge = c.ViewportToWorldPoint(Vector3.one); float randX = UnityEngine.Random.Range(RepositionLogic.MinXPercent, RepositionLogic.MaxXPercent); float randY = UnityEngine.Random.Range(RepositionLogic.MinYPercent, RepositionLogic.MaxYPercent); Vector3 newWorldPoint = c.ViewportToWorldPoint(new Vector3(randX, randY)); InfiniteScroll.SetPosition(obj, r, newWorldPoint.x, topEdge.y + newWorldPoint.y); } } } } }
public void SetupPosition(InfiniteScroll p, Camera c, int index) { Vector3 screenLeft = c.ViewportToWorldPoint(Vector3.zero); Vector3 screenTop = c.ViewportToWorldPoint(Vector3.one); float start, offset; if (p.IsHorizontal) { start = screenTop.y + 1.0f; offset = screenLeft.x + GameObjectRenderers[0].bounds.size.x; } else { start = screenTop.x + 1.0f; offset = screenLeft.y + GameObjectRenderers[0].bounds.size.y; } for (int i = 0; i < GameObjects.Count; i++) { GameObject obj = GameObjects[i]; Renderer r = GameObjectRenderers[i]; if (RepositionLogic.SortingOrder != 0) { r.sortingOrder = RepositionLogic.SortingOrder; } if (RepositionLogic.PositionMode == FreeParallaxPositionMode.IndividualStartOffScreen || RepositionLogic.PositionMode == FreeParallaxPositionMode.IndividualStartOnScreen) { float x, y; if (p.IsHorizontal) { x = (RepositionLogic.PositionMode == FreeParallaxPositionMode.IndividualStartOnScreen ? r.bounds.min.x : 0); y = (RepositionLogic.PositionMode == FreeParallaxPositionMode.IndividualStartOnScreen ? r.bounds.min.y : start + r.bounds.size.y); } else { x = (RepositionLogic.PositionMode == FreeParallaxPositionMode.IndividualStartOnScreen ? r.bounds.min.x : start + r.bounds.size.x); y = (RepositionLogic.PositionMode == FreeParallaxPositionMode.IndividualStartOnScreen ? r.bounds.min.y : 0); } InfiniteScroll.SetPosition(obj, r, x, y); } else { // position in the next spot in line if (p.IsHorizontal) { offset -= (r.bounds.size.x - p.WrapOverlap); } else { offset -= (r.bounds.size.y - p.WrapOverlap); } obj.transform.rotation = Quaternion.identity; // anchor to the top of the screen if (RepositionLogic.PositionMode == FreeParallaxPositionMode.WrapAnchorTop) { if (p.IsHorizontal) { Vector3 topWorld = c.ViewportToWorldPoint(new Vector3(0.0f, 1.0f, 0.0f)); InfiniteScroll.SetPosition(obj, r, offset, topWorld.y - r.bounds.size.y); } else { Vector3 topWorld = c.ViewportToWorldPoint(new Vector3(1.0f, 0.0f, 0.0f)); InfiniteScroll.SetPosition(obj, r, topWorld.x - r.bounds.size.x, offset + r.bounds.size.y); } } else if (RepositionLogic.PositionMode == FreeParallaxPositionMode.WrapAnchorBottom) { if (p.IsHorizontal) { InfiniteScroll.SetPosition(obj, r, offset, screenLeft.y); } else { InfiniteScroll.SetPosition(obj, r, screenLeft.x, offset); } } else { // no anchor, maintain position if (p.IsHorizontal) { InfiniteScroll.SetPosition(obj, r, offset, r.bounds.min.y); } else { InfiniteScroll.SetPosition(obj, r, r.bounds.min.x, offset); } } GameObjects.RemoveAt(i); GameObjects.Insert(0, obj); GameObjectRenderers.RemoveAt(i); GameObjectRenderers.Insert(0, r); } } }
public void SetupScale(InfiniteScroll p, Camera c, int index) { Vector3 worldBottom = c.ViewportToWorldPoint(Vector3.zero); for (int i = 0; i < GameObjects.Count; i++) { GameObject obj = GameObjects[i]; Renderer r = GameObjectRenderers[i]; Bounds b = r.bounds; if (RepositionLogic.ScaleHeight > 0.0f) { float percent; obj.transform.localScale = Vector3.one; if (p.IsHorizontal) { Vector3 maxPoint = c.WorldToViewportPoint(new Vector3(0.0f, worldBottom.y + b.size.y, 0.0f)); percent = RepositionLogic.ScaleHeight / maxPoint.y; } else { Vector3 maxPoint = c.WorldToViewportPoint(new Vector3(worldBottom.x + b.size.x, 0.0f, 0.0f)); percent = RepositionLogic.ScaleHeight / maxPoint.x; } obj.transform.localScale = new Vector3(percent, percent, 1); b = r.bounds; } if (RepositionLogic.PositionMode != FreeParallaxPositionMode.IndividualStartOffScreen && RepositionLogic.PositionMode != FreeParallaxPositionMode.IndividualStartOnScreen && SpeedRatio > 0.0f) { if (p.IsHorizontal) { // if we aren't at least a viewport width * 1.1, resize in x only (a little stretching and we'll log a warning) float objWidth = c.WorldToViewportPoint(new Vector3(worldBottom.x + b.size.x, 0, 0)).x; if (objWidth < 1.1f) { Debug.LogWarning("Game object in element index " + index.ToString() + " did not fit the screen width but was asked to wrap, so it was stretched. This can be fixed " + "by making sure any parallax graphics that wrap are at least 1.1x times the largest width resolution you support."); Vector3 scale = obj.transform.localScale; scale.x = (scale.x * (1.0f / objWidth)) + 0.1f; obj.transform.localScale = scale; } } else { // if we aren't at least a viewport height * 1.1, resize in y only (a little stretching and we'll log a warning) float objHeight = c.WorldToViewportPoint(new Vector3(0.0f, worldBottom.y + b.size.y, 0.0f)).y; if (objHeight < 1.1f) { Debug.LogWarning("Game object in element index " + index.ToString() + " did not fit the screen height but was asked to wrap, so it was stretched. This can be fixed " + "by making sure any parallax graphics that wrap are at least 1.1x times the largest height resolution you support."); Vector3 scale = obj.transform.localScale; scale.y = (scale.y * (1.0f / objHeight)) + 0.1f; obj.transform.localScale = scale; } } } } }