How to add a SC Scroll to top widget in portal

Gopal14
Tera Contributor

Hi,

 

I want to add SC Scroll to top widget in the portal. 

How can I add?

@Aman Singh @Anil Lande @Ankur Bawiskar @Mark Roethof 

@Mark Stanger 

1 ACCEPTED SOLUTION

AnirudhKumar
Mega Sage
Mega Sage

The OOB SC Scroll to top widget works only on mobile devices.

I've stolen parts of the code to make it work for all devices.

 

Create a new widget and add below components:

HTML:

<button class="btn fa fa-arrow-up fa-lg padder-lg button-to-top pull-right" ng-click="goToTop()" ></button>

 

Client  Controller:(Note: In your client controller, add spUtil as parameter to the main function)

$scope.goToTop= function()
	{
		spUtil.scrollTo('.sp-scroll', 300);
	}

 

CSS:

.button-to-top {
    position: fixed;
    bottom: 0;
    right: 0;
    margin-right: 15px;
    margin-bottom: 15px;
    border-radius: 5px !important;
    opacity: 0.7 !important;
    padding: 12px !important;
    border: 1px solid !important;
    width: 47px;
    height: 45px;
    background-color: #ddd;
  }

 

Add this widget to your page, and your functionality should be ready.

 

 

Long Live ServiceNow!

View solution in original post

5 REPLIES 5

AnirudhKumar
Mega Sage
Mega Sage

The OOB SC Scroll to top widget works only on mobile devices.

I've stolen parts of the code to make it work for all devices.

 

Create a new widget and add below components:

HTML:

<button class="btn fa fa-arrow-up fa-lg padder-lg button-to-top pull-right" ng-click="goToTop()" ></button>

 

Client  Controller:(Note: In your client controller, add spUtil as parameter to the main function)

$scope.goToTop= function()
	{
		spUtil.scrollTo('.sp-scroll', 300);
	}

 

CSS:

.button-to-top {
    position: fixed;
    bottom: 0;
    right: 0;
    margin-right: 15px;
    margin-bottom: 15px;
    border-radius: 5px !important;
    opacity: 0.7 !important;
    padding: 12px !important;
    border: 1px solid !important;
    width: 47px;
    height: 45px;
    background-color: #ddd;
  }

 

Add this widget to your page, and your functionality should be ready.

 

 

Long Live ServiceNow!

HI Anirudh 

I had used the same Code , i got the button in homepage but not Working 

As the button need to scroll up its not working 

Is there any changes need to done

Thanks

You have to add spUtil in the main controller function

John Johnson
Kilo Sage

Example of adding spUtil in the main controller function?