---
layout: home
search_exclude: true
---
# fastquant :nerd_face: — Backtest and optimize your trading strategies with only 3 lines of code!
## Free software: [fastquant for Python and R](https://github.com/enzoampil/fastquant)
# Blog Posts
Detailed tutorials that explain a lot of the concepts behind fastquant's capabilities!
## [Introduction to forecasting Philippine stock prices using Facebook’s Prophet](https://towardsdatascience.com/introduction-to-forecasting-philippine-stock-prices-fd4df5dad9c3?source=friends_link&sk=e0b90bdd8e2716b832d3bf66233c6fbe)
## [Access Philippine Stock Data with Only 2 Lines of Python](https://towardsdatascience.com/access-philippine-stock-data-with-only-2-lines-of-python-309780382b8d?source=friends_link&sk=d4eab964eae7407a62690e4be1c165d7)
## [Backtest Your Trading Strategy with Only 3 Lines of Python](https://towardsdatascience.com/backtest-your-trading-strategy-with-only-3-lines-of-python-3859b4a4ab44?source=friends_link&sk=ec647b6bb43fe322013248fd1d473015)
## [Backtest with grid search using only 3 lines of code on fastquant](https://towardsdatascience.com/backtest-with-grid-search-using-only-3-lines-of-code-on-fastquant-551615fdaf69?source=friends_link&sk=bae7a13f85707fc0ef57f3be1312ec7a)
# Video Tutorials
Video tutorials that show you first hand how to use fastquant!
## [Lesson 1: Basic Stock Price Analysis on Jollibee Food Corp. (JFC) with fastquant](https://www.youtube.com/watch?v=Yf0nZ7C45zY)
## [Lesson 2: Backtest your trading strategy w/ only 3 lines of code with fastquant](https://www.youtube.com/watch?v=sYn8Qj9ozKo)
# Technical Tutorials
Hands on coding articles that show you how to use fastquant in detail. You can also find our example notebooks [here](https://nbviewer.jupyter.org/github/enzoampil/fastquant/tree/master/examples/).


src.species package¶
Submodules¶
src.species.species module¶
-
class
src.species.species.
Species
(nodes, colorset, colormap, strandgraph)[source]¶ Bases:
object
Species (DNA Complexes) consists of one or more strands
-
canonicalform
= ''¶ canonical form
-
static
check_pendingbond
(b, pending)[source]¶ check if b is in pending bonds
- Parameters
b – domain
pending – pending bonds
- Returns
the bond number if b is in pending bond, -1 otherwise
-
colormap
= {}¶ map colors to nodes
-
colorset
= {}¶ set of colors
-
derive_canonical_form
(strandgraph)[source]¶ derive a canonical form for the species
- Parameters
strandgraph – a StrandGraph object
-
get_starting_vertex
(strandgraph)[source]¶ find the starting vertex to do derive canonical function
- Parameters
strandgraph – a StrandGraph object
- Returns
starting vertex id(strand id)
-
id
= -1¶ species id
-
nodes
= []¶ strand ids in the species
-
parsingseq
= []¶ parsing sequence for deriving canonical form
-
prune
(nodes, strandgraph)[source]¶ Pruning algorithm for selecting starting vertex :param nodes: candidate nodes :param strandgraph: :return:
-
prune_starting_vertices
(rootv, prevnodes, nodes, bondgraph, notvisited)[source]¶ deprecated prune starting vertices (strands) when there are more than one instances of one strand type
- Parameters
rootv – rootmap for nodes (map current nodes to their root nodes)
prevnodes – previous layer of nodes
nodes – current layer of nodes
bondgraph – a BondGraph object
notvisited – list of not visited nodes
- Returns
starting vertex
-
static
refresh_for_pruning
(v, d, n2, c2, d2)[source]¶ deprecated :param v: :param d: :param n2: :param c2: :param d2: :return:
-
strands
= []¶ strands
-
traverse
(strandgraph, curv, q, bondnum, pendingbond, canonical, visited)[source]¶ traverse the strand and produce a canonical form
- Parameters
strandgraph – a StrandGraph object
curv – current vertex in strandgraph
q – queue for determining if all nodes in species has been encountered
bondnum – number of bonds
pendingbond – list of bonds (in domain level) that are pending to add
canonical – canonical form
visited – boolean list for visiting vertices in species
- Returns
canonical form for one strand
-
src.species.species_explore module¶
-
src.species.species_explore.
bi
(speciescomb, specieslist, speciesidmap, reactionlist, kinetics)[source]¶ bi-molecule reaction
- Parameters
reactionlist –
speciescomb – combinations of species ids
specieslist –
speciesidmap –
- Returns
specieslist, speciesidmap
-
src.species.species_explore.
check_existence
(species, specieslist, speciesidmap)[source]¶ check if the produced species is new in the DSD system
- Parameters
species – produced species
specieslist – list of species in the system
speciesidmap – bi-directional map of species id and species canonical form
- Returns
specieslist, speciesidmap
-
src.species.species_explore.
generate_colorinfo
(color)[source]¶ generate color information based on strand graph’s color
- Parameters
color – strand graph’s color
- Returns
colorset: a set of color colormap: a map of color to id of the strand
-
src.species.species_explore.
generate_multiple_species
(strandgraph, specieslist, speciesidmap, reaction)[source]¶ generate multiple species (applies when unbinding and migrating)
- Parameters
reaction –
strandgraph –
specieslist –
speciesidmap –
- Returns


MsgBlast
Try the alpha!
Message
Contacts
Send a copy to yourself
Our service is temporary offline, sorry for the inconvenience.


Search
- Search repositories
- Search commits
- Search code
- Search issues and pull requests
- Search users
- Search topics
- Search labels
- Text match metadata
The Search API helps you search for the specific item you want to find. For example, you can find a user or a specific file in a repository. Think of it the way you think of performing a search on Google. It's designed to help you find the one result you're looking for (or maybe the few results you're looking for). Just like searching on Google, you sometimes want to see a few pages of search results so that you can find the item that best meets your needs. To satisfy that need, the GitHub Enterprise Search API provides up to 1,000 results for each search.
You can narrow your search using queries. To learn more about the search query syntax, see "Constructing a search query."
Ranking search results
Unless another sort option is provided as a query parameter, results are sorted
by best match, as indicated by the score
field for each item returned. This
is a computed value representing the relevance of an item relative to the other
items in the result set. Multiple factors are combined to boost the most
relevant item to the top of the result list.
Rate limit
The Search API has a custom rate limit. For requests using Basic Authentication, OAuth, or client ID and secret, you can make up to 30 requests per minute. For unauthenticated requests, the rate limit allows you to make up to 10 requests per minute.
Note that the limits mentioned above are the default rate limits for a GitHub Enterprise Server instance. Contact your site administrator to confirm if rate limits are enabled and how they are configured.
See the rate limit documentation for details on determining your current rate limit status.
Constructing a search query
Each endpoint in the Search API uses query parameters to perform searches on GitHub Enterprise. See the individual endpoint in the Search API for an example that includes the endpoint and query parameters.
A query can contain any combination of search qualifiers supported on GitHub.com. The format of the search query is:
q=SEARCH_KEYWORD_1+SEARCH_KEYWORD_N+QUALIFIER_1+QUALIFIER_N
For example, if you wanted to search for all repositories owned by defunkt
that
contained the word GitHub
and Octocat
in the README file, you would use the
following query with the search repositories endpoint:
q=GitHub+Octocat+in:readme+user:defunkt
See "Searching on GitHub" for a complete list of available qualifiers, their format, and an example of how to use them. For information about how to use operators to match specific quantities, dates, or to exclude results, see "Understanding the search syntax."
Limitations on query length
The Search API does not support queries that:
- are longer than 256 characters (not including operators or qualifiers).
- have more than five
AND
,OR
, orNOT
operators.
These search queries will return a "Validation failed" error message.
Timeouts and incomplete results
To keep the Search API fast for everyone, we limit how long any individual query
can run. For queries that exceed the time limit,
the API returns the matches that were already found prior to the timeout, and
the response has the incomplete_results
property set to true
.
Reaching a timeout does not necessarily mean that search results are incomplete. More results might have been found, but also might not.
Access errors or missing search results
You need to successfully authenticate and have access to the repositories in your search queries, otherwise, you'll see a 422 Unprocessible Entry
error with a "Validation Failed" message. For example, your search will fail if your query includes repo:
, user:
, or org:
qualifiers that request resources that you don't have access to when you sign in on GitHub.
When your search query requests multiple resources, the response will only contain the resources that you have access to and will not provide an error message listing the resources that were not returned.
For example, if your search query searches for the octocat/test
and codertocat/test
repositories, but you only have access to octocat/test
, your response will show search results for octocat/test
and nothing for codertocat/test
. This behavior mimics how search works on GitHub.
Search repositories
Note: The topics
property for repositories on GitHub Enterprise is currently available for developers to preview. To view the topics
property in calls that return repository results, you must provide a custom media type in the Accept
header:
application/vnd.github.mercy-preview+json
Warning: The API may change without advance notice during the preview period. Preview features are not supported for production use. If you experience any issues, contact your GitHub Enterprise site administrator.
Find repositories via various criteria. This method returns up to 100 results per page.
When searching for repositories, you can get text match metadata for the
name and description fields when you pass the text-match
media type.
For more details about how to receive highlighted search results, see Text match metadata.
GET /search/repositories
Parameters
| Name | Type | Description |
|---|---|---|
q |
string |
Required. The query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as GitHub.com. To learn more about the format of the query, see Constructing a search query. See "Searching for repositories" for a detailed list of qualifiers. |
sort |
string |
Sorts the results of your query by number of stars , forks , or help-wanted-issues or how recently the items were updated . Default: best match
|
order |
string |
Determines whether the first search result returned is the highest number of matches (desc ) or lowest number of matches (asc ). This parameter is ignored unless you provide sort . Default: desc
|
Example
Suppose you want to search for popular Tetris repositories written in Assembly. Your query might look like this.
curl http(s)://[hostname]/api/v3/search/repositories?q=tetris+language:assembly&sort=stars&order=desc
You can search for multiple topics by adding more topic:
instances, and including the mercy-preview
header. For example:
curl -H "Accept: application/vnd.github.mercy-preview+json" \ http(s)://[hostname]/api/v3/search/repositories?q=topic:ruby+topic:rails
In this request, we're searching for repositories with the word tetris
in the
name, the description, or the README. We're limiting the results to only find
repositories where the primary language is Assembly. We're sorting by stars in
descending order, so that the most popular repositories appear first in the
search results.
Status: 200 OK
Link: <https://api.github.com/resource?page=2>; rel="next",
<https://api.github.com/resource?page=5>; rel="last"
X-RateLimit-Limit: 20
X-RateLimit-Remaining: 19
{
"total_count": 40,
"incomplete_results": false,
"items": [
{
"id": 3081286,
"node_id": "MDEwOlJlcG9zaXRvcnkzMDgxMjg2",
"name": "Tetris",
"full_name": "dtrupenn/Tetris",
"owner": {
"login": "dtrupenn",
"id": 872147,
"node_id": "MDQ6VXNlcjg3MjE0Nw==",
"avatar_url": "https://secure.gravatar.com/avatar/e7956084e75f239de85d3a31bc172ace?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png",
"gravatar_id": "",
"url": "https://api.github.com/users/dtrupenn",
"received_events_url": "https://api.github.com/users/dtrupenn/received_events",
"type": "User"
},
"private": false,
"html_url": "https://github.com/dtrupenn/Tetris",
"description": "A C implementation of Tetris using Pennsim through LC4",
"fork": false,
"url": "https://api.github.com/repos/dtrupenn/Tetris",
"created_at": "2012-01-01T00:31:50Z",
"updated_at": "2013-01-05T17:58:47Z",
"pushed_at": "2012-01-01T00:37:02Z",
"homepage": "",
"size": 524,
"stargazers_count": 1,
"watchers_count": 1,
"language": "Assembly",
"forks_count": 0,
"open_issues_count": 0,
"master_branch": "master",
"default_branch": "master",
"score": 10.309712
}
]
}
Search commits
Note: The Commit Search API is currently available for developers to preview. During the preview period, the APIs may change without advance notice. Please see the blog post for full details.
To access the API you must provide a custom media type in the Accept
header:
application/vnd.github.cloak-preview
Warning: The API may change without advance notice during the preview period. Preview features are not supported for production use. If you experience any issues, contact your GitHub Enterprise site administrator.
Find commits via various criteria. This method returns up to 100 results per page.
When searching for commits, you can get text match metadata for the message
field when you provide the text-match
media type.
For more details about how to receive highlighted search results, see Text match metadata.
GET /search/commits
Considerations for commit search
Only the default branch is considered. In most cases, this will be the master
branch.
Parameters
| Name | Type | Description |
|---|---|---|
q |
string |
Required. The query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as GitHub.com. To learn more about the format of the query, see Constructing a search query. See "Searching commits" for a detailed list of qualifiers. |
sort |
string |
Sorts the results of your query by author-date or committer-date . Default: best match
|
order |
string |
Determines whether the first search result returned is the highest number of matches (desc ) or lowest number of matches (asc ). This parameter is ignored unless you provide sort . Default: desc
|
Example
Suppose you want to find commits related to CSS in the octocat/Spoon-Knife repository. Your query would look something like this:
curl -H "Accept: application/vnd.github.cloak-preview" \ http(s)://[hostname]/api/v3/search/commits?q=repo:octocat/Spoon-Knife+css
Status: 200 OK
Link: <https://api.github.com/resource?page=2>; rel="next",
<https://api.github.com/resource?page=5>; rel="last"
X-RateLimit-Limit: 20
X-RateLimit-Remaining: 19
{
"total_count": 1,
"incomplete_results": false,
"items": [
{
"url": "https://api.github.com/repos/octocat/Spoon-Knife/commits/bb4cc8d3b2e14b3af5df699876dd4ff3acd00b7f",
"sha": "bb4cc8d3b2e14b3af5df699876dd4ff3acd00b7f",
"html_url": "https://github.com/octocat/Spoon-Knife/commit/bb4cc8d3b2e14b3af5df699876dd4ff3acd00b7f",
"comments_url": "https://api.github.com/repos/octocat/Spoon-Knife/commits/bb4cc8d3b2e14b3af5df699876dd4ff3acd00b7f/comments",
"commit": {
"url": "https://api.github.com/repos/octocat/Spoon-Knife/git/commits/bb4cc8d3b2e14b3af5df699876dd4ff3acd00b7f",
"author": {
"date": "2014-02-04T14:38:36-08:00",
"name": "The Octocat",
"email"<EMAIL_ADDRESS>},
"committer": {
"date": "2014-02-12T15:18:55-08:00",
"name": "The Octocat",
"email"<EMAIL_ADDRESS>},
"message": "Create styles.css and updated README",
"tree": {
"url": "https://api.github.com/repos/octocat/Spoon-Knife/git/trees/a639e96f9038797fba6e0469f94a4b0cc459fa68",
"sha": "a639e96f9038797fba6e0469f94a4b0cc459fa68"
},
"comment_count": 8
},
"author": {
"login": "octocat",
"id": 583231,
"node_id": "MDQ6VXNlcjU4MzIzMQ==",
"avatar_url": "https://avatars.githubusercontent.com/u/583231?v=3",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"committer": {
"login": "octocat",
"id": 583231,
"node_id": "MDQ6VXNlcjU4MzIzMQ==",
"avatar_url": "https://avatars.githubusercontent.com/u/583231?v=3",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"parents": [
{
"url": "https://api.github.com/repos/octocat/Spoon-Knife/commits/a30c19e3f13765a3b48829788bc1cb8b4e95cee4",
"html_url": "https://github.com/octocat/Spoon-Knife/commit/a30c19e3f13765a3b48829788bc1cb8b4e95cee4",
"sha": "a30c19e3f13765a3b48829788bc1cb8b4e95cee4"
}
],
"repository": {
"id": 1300192,
"node_id": "MDEwOlJlcG9zaXRvcnkxMzAwMTky",
"name": "Spoon-Knife",
"full_name": "octocat/Spoon-Knife",
"owner": {
"login": "octocat",
"id": 583231,
"node_id": "MDQ6VXNlcjU4MzIzMQ==",
"avatar_url": "https://avatars.githubusercontent.com/u/583231?v=3",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"private": false,
"html_url": "https://github.com/octocat/Spoon-Knife",
"description": "This repo is for demonstration purposes only.",
"fork": false,
"url": "https://api.github.com/repos/octocat/Spoon-Knife",
"forks_url": "https://api.github.com/repos/octocat/Spoon-Knife/forks",
"keys_url": "https://api.github.com/repos/octocat/Spoon-Knife/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/octocat/Spoon-Knife/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/octocat/Spoon-Knife/teams",
"hooks_url": "https://api.github.com/repos/octocat/Spoon-Knife/hooks",
"issue_events_url": "https://api.github.com/repos/octocat/Spoon-Knife/issues/events{/number}",
"events_url": "https://api.github.com/repos/octocat/Spoon-Knife/events",
"assignees_url": "https://api.github.com/repos/octocat/Spoon-Knife/assignees{/user}",
"branches_url": "https://api.github.com/repos/octocat/Spoon-Knife/branches{/branch}",
"tags_url": "https://api.github.com/repos/octocat/Spoon-Knife/tags",
"blobs_url": "https://api.github.com/repos/octocat/Spoon-Knife/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/octocat/Spoon-Knife/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/octocat/Spoon-Knife/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/octocat/Spoon-Knife/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/octocat/Spoon-Knife/statuses/{sha}",
"languages_url": "https://api.github.com/repos/octocat/Spoon-Knife/languages",
"stargazers_url": "https://api.github.com/repos/octocat/Spoon-Knife/stargazers",
"contributors_url": "https://api.github.com/repos/octocat/Spoon-Knife/contributors",
"subscribers_url": "https://api.github.com/repos/octocat/Spoon-Knife/subscribers",
"subscription_url": "https://api.github.com/repos/octocat/Spoon-Knife/subscription",
"commits_url": "https://api.github.com/repos/octocat/Spoon-Knife/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/octocat/Spoon-Knife/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/octocat/Spoon-Knife/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/octocat/Spoon-Knife/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/octocat/Spoon-Knife/contents/{+path}",
"compare_url": "https://api.github.com/repos/octocat/Spoon-Knife/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/octocat/Spoon-Knife/merges",
"archive_url": "https://api.github.com/repos/octocat/Spoon-Knife/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/octocat/Spoon-Knife/downloads",
"issues_url": "https://api.github.com/repos/octocat/Spoon-Knife/issues{/number}",
"pulls_url": "https://api.github.com/repos/octocat/Spoon-Knife/pulls{/number}",
"milestones_url": "https://api.github.com/repos/octocat/Spoon-Knife/milestones{/number}",
"notifications_url": "https://api.github.com/repos/octocat/Spoon-Knife/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/octocat/Spoon-Knife/labels{/name}",
"releases_url": "https://api.github.com/repos/octocat/Spoon-Knife/releases{/id}",
"deployments_url": "https://api.github.com/repos/octocat/Spoon-Knife/deployments"
},
"score": 4.9971514
}
]
}
Search code
Find file contents via various criteria. This method returns up to 100 results per page.
When searching for code, you can get text match metadata for the file content
and file path fields when you pass the text-match
media type.
For more details about how to receive highlighted search results, see Text match metadata.
GET /search/code
Considerations for code search
Due to the complexity of searching code, there are a few restrictions on how searches are performed:
- Only the default branch is considered. In most cases, this will be the
master
branch. - Only files smaller than 10 MB are searchable.
Parameters
| Name | Type | Description |
|---|---|---|
q |
string |
Required. The query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as GitHub.com. To learn more about the format of the query, see Constructing a search query. See "Searching code" for a detailed list of qualifiers. |
sort |
string |
Sorts the results of your query. Can only be indexed , which indicates how recently a file has been indexed by the GitHub Enterprise search infrastructure. Default: best match
|
order |
string |
Determines whether the first search result returned is the highest number of matches (desc ) or lowest number of matches (asc ). This parameter is ignored unless you provide sort . Default: desc
|
Example
Suppose you want to find the definition of the addClass
function inside
jQuery. Your query would look something like
this:
curl http(s)://[hostname]/api/v3/search/code?q=addClass+in:file+language:js+repo:jquery/jquery
Here, we're searching for the keyword addClass
within a file's contents. We're
making sure that we're only looking in files where the language is JavaScript.
And we're scoping the search to the repo:jquery/jquery
repository.
Status: 200 OK
Link: <https://api.github.com/resource?page=2>; rel="next",
<https://api.github.com/resource?page=5>; rel="last"
X-RateLimit-Limit: 20
X-RateLimit-Remaining: 19
{
"total_count": 7,
"incomplete_results": false,
"items": [
{
"name": "classes.js",
"path": "src/attributes/classes.js",
"sha": "d7212f9dee2dcc18f084d7df8f417b80846ded5a",
"url": "https://api.github.com/repositories/167174/contents/src/attributes/classes.js?ref=825ac3773694e0cd23ee74895fd5aeb535b27da4",
"git_url": "https://api.github.com/repositories/167174/git/blobs/d7212f9dee2dcc18f084d7df8f417b80846ded5a",
"html_url": "https://github.com/jquery/jquery/blob/825ac3773694e0cd23ee74895fd5aeb535b27da4/src/attributes/classes.js",
"repository": {
"id": 167174,
"node_id": "MDEwOlJlcG9zaXRvcnkxNjcxNzQ=",
"name": "jquery",
"full_name": "jquery/jquery",
"owner": {
"login": "jquery",
"id": 70142,
"node_id": "MDQ6VXNlcjcwMTQy",
"avatar_url": "https://0.gravatar.com/avatar/6906f317a4733f4379b06c32229ef02f?d=https%3A%2F%2Fidenticons.github.com%2Ff426f04f2f9813718fb806b30e0093de.png",
"gravatar_id": "",
"url": "https://api.github.com/users/jquery",
"html_url": "https://github.com/jquery",
"followers_url": "https://api.github.com/users/jquery/followers",
"following_url": "https://api.github.com/users/jquery/following{/other_user}",
"gists_url": "https://api.github.com/users/jquery/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jquery/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jquery/subscriptions",
"organizations_url": "https://api.github.com/users/jquery/orgs",
"repos_url": "https://api.github.com/users/jquery/repos",
"events_url": "https://api.github.com/users/jquery/events{/privacy}",
"received_events_url": "https://api.github.com/users/jquery/received_events",
"type": "Organization",
"site_admin": false
},
"private": false,
"html_url": "https://github.com/jquery/jquery",
"description": "jQuery JavaScript Library",
"fork": false,
"url": "https://api.github.com/repos/jquery/jquery",
"forks_url": "https://api.github.com/repos/jquery/jquery/forks",
"keys_url": "https://api.github.com/repos/jquery/jquery/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/jquery/jquery/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/jquery/jquery/teams",
"hooks_url": "https://api.github.com/repos/jquery/jquery/hooks",
"issue_events_url": "https://api.github.com/repos/jquery/jquery/issues/events{/number}",
"events_url": "https://api.github.com/repos/jquery/jquery/events",
"assignees_url": "https://api.github.com/repos/jquery/jquery/assignees{/user}",
"branches_url": "https://api.github.com/repos/jquery/jquery/branches{/branch}",
"tags_url": "https://api.github.com/repos/jquery/jquery/tags",
"blobs_url": "https://api.github.com/repos/jquery/jquery/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/jquery/jquery/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/jquery/jquery/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/jquery/jquery/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/jquery/jquery/statuses/{sha}",
"languages_url": "https://api.github.com/repos/jquery/jquery/languages",
"stargazers_url": "https://api.github.com/repos/jquery/jquery/stargazers",
"contributors_url": "https://api.github.com/repos/jquery/jquery/contributors",
"subscribers_url": "https://api.github.com/repos/jquery/jquery/subscribers",
"subscription_url": "https://api.github.com/repos/jquery/jquery/subscription",
"commits_url": "https://api.github.com/repos/jquery/jquery/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/jquery/jquery/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/jquery/jquery/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/jquery/jquery/issues/comments/{number}",
"contents_url": "https://api.github.com/repos/jquery/jquery/contents/{+path}",
"compare_url": "https://api.github.com/repos/jquery/jquery/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/jquery/jquery/merges",
"archive_url": "https://api.github.com/repos/jquery/jquery/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/jquery/jquery/downloads",
"issues_url": "https://api.github.com/repos/jquery/jquery/issues{/number}",
"pulls_url": "https://api.github.com/repos/jquery/jquery/pulls{/number}",
"milestones_url": "https://api.github.com/repos/jquery/jquery/milestones{/number}",
"notifications_url": "https://api.github.com/repos/jquery/jquery/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/jquery/jquery/labels{/name}"
},
"score": 0.5269679
}
]
}
Search issues and pull requests
Find issues by state and keyword. This method returns up to 100 results per page.
When searching for issues, you can get text match metadata for the issue
title, issue body, and issue comment body fields when you pass the
text-match
media type. For more details about how to receive highlighted search results, see Text match metadata.
GET /search/issues
Parameters
| Name | Type | Description |
|---|---|---|
q |
string |
Required. The query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as GitHub.com. To learn more about the format of the query, see Constructing a search query. See "Searching issues and pull requests" for a detailed list of qualifiers. |
sort |
string |
Sorts the results of your query by the number of comments , reactions , reactions-+1 , reactions--1 , reactions-smile , reactions-thinking_face , reactions-heart , reactions-tada , or interactions . You can also sort results by how recently the items were created or updated , Default: best match
|
order |
string |
Determines whether the first search result returned is the highest number of matches (desc ) or lowest number of matches (asc ). This parameter is ignored unless you provide sort . Default: desc
|
Example
Let's say you want to find the oldest unresolved Python bugs on Windows. Your query might look something like this.
curl http(s)://[hostname]/api/v3/search/issues?q=windows+label:bug+language:python+state:open&sort=created&order=asc
In this query, we're searching for the keyword windows
, within any open issue
that's labeled as bug
. The search runs across repositories whose primary
language is Python. We’re sorting by creation date in ascending order, so that
the oldest issues appear first in the search results.
Status: 200 OK
Link: <https://api.github.com/resource?page=2>; rel="next",
<https://api.github.com/resource?page=5>; rel="last"
X-RateLimit-Limit: 20
X-RateLimit-Remaining: 19
{
"total_count": 280,
"incomplete_results": false,
"items": [
{
"url": "https://api.github.com/repos/batterseapower/pinyin-toolkit/issues/132",
"repository_url": "https://api.github.com/repos/batterseapower/pinyin-toolkit",
"labels_url": "https://api.github.com/repos/batterseapower/pinyin-toolkit/issues/132/labels{/name}",
"comments_url": "https://api.github.com/repos/batterseapower/pinyin-toolkit/issues/132/comments",
"events_url": "https://api.github.com/repos/batterseapower/pinyin-toolkit/issues/132/events",
"html_url": "https://github.com/batterseapower/pinyin-toolkit/issues/132",
"id": 35802,
"node_id": "MDU6SXNzdWUzNTgwMg==",
"number": 132,
"title": "Line Number Indexes Beyond 20 Not Displayed",
"user": {
"login": "Nick3C",
"id": 90254,
"node_id": "MDQ6VXNlcjkwMjU0",
"avatar_url": "https://secure.gravatar.com/avatar/934442aadfe3b2f4630510de416c5718?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png",
"gravatar_id": "",
"url": "https://api.github.com/users/Nick3C",
"html_url": "https://github.com/Nick3C",
"followers_url": "https://api.github.com/users/Nick3C/followers",
"following_url": "https://api.github.com/users/Nick3C/following{/other_user}",
"gists_url": "https://api.github.com/users/Nick3C/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Nick3C/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Nick3C/subscriptions",
"organizations_url": "https://api.github.com/users/Nick3C/orgs",
"repos_url": "https://api.github.com/users/Nick3C/repos",
"events_url": "https://api.github.com/users/Nick3C/events{/privacy}",
"received_events_url": "https://api.github.com/users/Nick3C/received_events",
"type": "User"
},
"labels": [
{
"id": 4,
"node_id": "MDU6TGFiZWw0",
"url": "https://api.github.com/repos/batterseapower/pinyin-toolkit/labels/bug",
"name": "bug",
"color": "ff0000"
}
],
"state": "open",
"assignee": null,
"milestone": null,
"comments": 15,
"created_at": "2009-07-12T20:10:41Z",
"updated_at": "2009-07-19T09:23:43Z",
"closed_at": null,
"pull_request": {
"html_url": null,
"diff_url": null,
"patch_url": null
},
"body": "...",
"score": 1.3859273
}
]
}
Search users
Find users via various criteria. This method returns up to 100 results per page.
When searching for users, you can get text match metadata for the issue
login, email, and name fields when you pass the text-match
media type.
For more details about highlighting search results, see Text match metadata.
For more details about how to receive highlighted search results, see Text match metadata.
GET /search/users
Parameters
| Name | Type | Description |
|---|---|---|
q |
string |
Required. The query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as GitHub.com. To learn more about the format of the query, see Constructing a search query. See "Searching users" for a detailed list of qualifiers. |
sort |
string |
Sorts the results of your query by number of followers or repositories , or when the person joined GitHub Enterprise. Default: best match
|
order |
string |
Determines whether the first search result returned is the highest number of matches (desc ) or lowest number of matches (asc ). This parameter is ignored unless you provide sort . Default: desc
|
Example
Imagine you're looking for a list of popular users. You might try out this query:
curl http(s)://[hostname]/api/v3/search/users?q=tom+repos:%3E42+followers:%3E1000
Here, we're looking at users with the name Tom. We're only interested in those with more than 42 repositories, and only if they have over 1,000 followers.
Status: 200 OK
Link: <https://api.github.com/resource?page=2>; rel="next",
<https://api.github.com/resource?page=5>; rel="last"
X-RateLimit-Limit: 20
X-RateLimit-Remaining: 19
{
"total_count": 12,
"incomplete_results": false,
"items": [
{
"login": "mojombo",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://secure.gravatar.com/avatar/25c7c18223fb42a4c6ae1c8db6f50f9b?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png",
"gravatar_id": "",
"url": "https://api.github.com/users/mojombo",
"html_url": "https://github.com/mojombo",
"followers_url": "https://api.github.com/users/mojombo/followers",
"subscriptions_url": "https://api.github.com/users/mojombo/subscriptions",
"organizations_url": "https://api.github.com/users/mojombo/orgs",
"repos_url": "https://api.github.com/users/mojombo/repos",
"received_events_url": "https://api.github.com/users/mojombo/received_events",
"type": "User",
"score": 105.47857
}
]
}
Search topics
Note: The topics
property for repositories on GitHub Enterprise is currently available for developers to preview. To view the topics
property in calls that return repository results, you must provide a custom media type in the Accept
header:
application/vnd.github.mercy-preview+json
Warning: The API may change without advance notice during the preview period. Preview features are not supported for production use. If you experience any issues, contact your GitHub Enterprise site administrator.
Find topics via various criteria. Results are sorted by best match. This method returns up to 100 results per page.
When searching for topics, you can get text match metadata for the topic's short_description,
description, name, or display_name field when you pass the text-match
media type. For more details about how to receive highlighted search results, see Text match metadata.
GET /search/topics
Parameters
| Name | Type | Description |
|---|---|---|
q |
string |
Required. The query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as GitHub.com. To learn more about the format of the query, see Constructing a search query. |
See "Searching topics" for a detailed list of qualifiers.
Example
Suppose you want to search for topics related to Ruby that are featured on https://github.com/topics. Your query might look like this:
curl -H 'Accept: application/vnd.github.mercy-preview+json' \ 'http(s)://[hostname]/api/v3/search/topics?q=ruby+is:featured'
In this request, we're searching for topics with the keyword ruby
, and we're limiting the results to find only topics that are featured. The topics that are the best match for the query appear first in the search results.
Note: A search for featured Ruby topics only has 6 total results, so a Link header indicating pagination is not included in the response.
Status: 200 OK
X-RateLimit-Limit: 20
X-RateLimit-Remaining: 19
{
"total_count": 6,
"incomplete_results": false,
"items": [
{
"name": "ruby",
"display_name": "Ruby",
"short_description": "Ruby is a scripting language designed for simplified object-oriented programming.",
"description": "Ruby was developed by Yukihiro \"Matz\" Matsumoto in 1995 with the intent of having an easily readable programming language. It is integrated with the Rails framework to create dynamic web-applications. Ruby's syntax is similar to that of Perl and Python.",
"created_by": "Yukihiro Matsumoto",
"released": "December 21, 1995",
"created_at": "2016-11-28T22:03:59Z",
"updated_at": "2017-10-30T18:16:32Z",
"featured": true,
"curated": true,
"score": 1750.5872
},
{
"name": "rails",
"display_name": "Rails",
"short_description": "Ruby on Rails (Rails) is a web application framework written in Ruby.",
"description": "Ruby on Rails (Rails) is a web application framework written in Ruby. It is meant to help simplify the building of complex websites.",
"created_by": "David Heinemeier Hansson",
"released": "December 13 2005",
"created_at": "2016-12-09T17:03:50Z",
"updated_at": "2017-10-30T16:20:19Z",
"featured": true,
"curated": true,
"score": 192.49863
},
{
"name": "python",
"display_name": "Python",
"short_description": "Python is a dynamically typed programming language.",
"description": "Python is a dynamically typed programming language designed by Guido Van Rossum. Much like the programming language Ruby, Python was designed to be easily read by programmers. Because of its large following and many libraries, Python can be implemented and used to do anything from webpages to scientific research.",
"created_by": "Guido van Rossum",
"released": "February 20, 1991",
"created_at": "2016-12-07T00:07:02Z",
"updated_at": "2017-10-27T22:45:43Z",
"featured": true,
"curated": true,
"score": 111.92691
},
{
"name": "jekyll",
"display_name": "Jekyll",
"short_description": "Jekyll is a simple, blog-aware static site generator.",
"description": "Jekyll is a blog-aware, site generator written in Ruby. It takes raw text files, runs it through a renderer and produces a publishable static website.",
"created_by": "Tom Preston-Werner",
"released": "2008",
"created_at": "2016-12-16T21:53:08Z",
"updated_at": "2017-10-27T19:00:24Z",
"featured": true,
"curated": true,
"score": 45.06729
},
{
"name": "sass",
"display_name": "Sass",
"short_description": "Sass is a stable extension to classic CSS.",
"description": "Sass is a stylesheet language with a main implementation in Ruby. It is an extension of CSS that makes improvements to the old stylesheet format, such as being able to declare variables and using a cleaner nesting syntax.",
"created_by": "Hampton Catlin, Natalie Weizenbaum, Chris Eppstein",
"released": "November 28, 2006",
"created_at": "2016-12-16T21:53:45Z",
"updated_at": "2018-01-16T16:30:40Z",
"featured": true,
"curated": true,
"score": 42.455986
},
{
"name": "homebrew",
"display_name": "Homebrew",
"short_description": "Homebrew is a package manager for macOS.",
"description": "Homebrew is a package manager for Apple's macOS operating system. It simplifies the installation of software and is popular in the Ruby on Rails community.",
"created_by": "Max Howell",
"released": "2009",
"created_at": "2016-12-17T20:30:44Z",
"updated_at": "2018-02-06T16:14:56Z",
"featured": true,
"curated": true,
"score": 19.194168
}
]
}
Search labels
Find labels in a repository with names or descriptions that match search keywords. Returns up to 100 results per page.
When searching for labels, you can get text match metadata for the label name
and description fields when you pass the text-match
media type.
For more details about how to receive highlighted search results, see Text match metadata.
GET /search/labels
Parameters
| Name | Type | Description |
|---|---|---|
repository_id |
integer |
Required. The id of the repository. |
q |
string |
Required. The search keywords. This endpoint does not accept qualifiers in the query. To learn more about the format of the query, see Constructing a search query. |
sort |
string |
Sorts the results of your query by when the label was created or updated . Default: best match
|
order |
string |
Determines whether the first search result returned is the highest number of matches (desc ) or lowest number of matches (asc ). This parameter is ignored unless you provide sort . Default: desc
|
Example
Suppose you want to find labels in the linguist
repository that match bug
, defect
, or enhancement
. Your query might look like this:
curl 'https://api.github.com/search/labels?repository_id=64778136&q=bug+defect+enhancement'
The labels that best match for the query appear first in the search results.
Status: 200 OK
{
"total_count": 2,
"incomplete_results": false,
"items": [
{
"id": 418327088,
"node_id": "MDU6TGFiZWw0MTgzMjcwODg=",
"url": "https://api.github.com/repos/octocat/linguist/labels/enhancement",
"name": "enhancement",
"color": "84b6eb",
"default": true,
"description": "New feature or request.",
"score": 0.1193385
},
{
"id": 418327086,
"node_id": "MDU6TGFiZWw0MTgzMjcwODY=",
"url": "https://api.github.com/repos/octocat/linguist/labels/bug",
"name": "bug",
"color": "ee0701",
"default": true,
"description": "Something isn't working.",
"score": 0.11928606
}
]
}
Text match metadata
On GitHub, you can use the context provided by code snippets and highlights in search results. The Search API offers additional metadata that allows you to highlight the matching search terms when displaying search results.
Requests can opt to receive those text fragments in the response, and every fragment is accompanied by numeric offsets identifying the exact location of each matching search term.
To get this metadata in your search results, specify the text-match
media type
in your Accept
header.
application/vnd.github.v3.text-match+json
When you provide the text-match
media type, you will receive an extra
key in the JSON payload called text_matches
that provides information about
the position of your search terms within the text and the property
that
includes the search term. Inside the text_matches
array, each object includes
the following attributes:
| Name | Description |
|---|---|
object_url |
The URL for the resource that contains a string property matching one of the search terms. |
object_type |
The name for the type of resource that exists at the given object_url . |
property |
The name of a property of the resource that exists at object_url . That property is a string that matches one of the search terms. (In the JSON returned from object_url , the full content for the fragment will be found in the property with this name.) |
fragment |
A subset of the value of property . This is the text fragment that matches one or more of the search terms. |
matches |
An array of one or more search terms that are present in fragment . The indices (i.e., "offsets") are relative to the fragment. (They are not relative to the full content of property .) |
Example
Using cURL, and the example issue search above, our API request would look like this:
curl -H 'Accept: application/vnd.github.v3.text-match+json' \ 'http(s)://[hostname]/api/v3/search/issues?q=windows+label:bug+language:python+state:open&sort=created&order=asc'
The response will include a text_matches
array for each search result. In the
JSON below, we have two objects in the text_matches
array.
The first text match occurred in the body
property of the issue. We see a
fragment of text from the issue body. The search term (windows
) appears twice
within that fragment, and we have the indices for each occurrence.
The second text match occurred in the body
property of one of the issue's
comments. We have the URL for the issue comment. And of course, we see a
fragment of text from the comment body. The search term (windows
) appears once
within that fragment.
{
"text_matches": [
{
"object_url": "https://api.github.com/repositories/215335/issues/132",
"object_type": "Issue",
"property": "body",
"fragment": "comprehensive windows font I know of).\n\nIf we can find a commonly distributed windows font that supports them then no problem (we can use html font tags) but otherwise the '(21)' style is probably better.\n",
"matches": [
{
"text": "windows",
"indices": [
14,
21
]
},
{
"text": "windows",
"indices": [
78,
85
]
}
]
},
{
"object_url": "https://api.github.com/repositories/215335/issues/comments/25688",
"object_type": "IssueComment",
"property": "body",
"fragment": " right after that are a bit broken IMHO :). I suppose we could have some hack that maxes out at whatever the font does...\n\nI'll check what the state of play is on Windows.\n",
"matches": [
{
"text": "Windows",
"indices": [
163,
170
]
}
]
}
]
}


HEAD ======= >>>>>>> alpha
This demo is very basic and shows only the most simple examples of using the JS-API wrapper.
You should have your javascript debugger console open when using it.
All requests are logging to the console so you can inspect the results.
This demo has been tested on Safari only.

Fill out the authentication credentials above, then you can populate the project / task drop-down.
Fill out the authentication credentials above, then you can populate the client drop-down.
Grabs information from the Cashboard API and displays it below.


javascript animation utility
npm install stimulate --save
Then:
import stimulate from 'stimulate';
stimulate({from:10, to:20});
or:
var stimulate = require('stimulate').stimulate;
stimulate({from:10, to:20});
or:

Stimulate helps you create animations with the following features:
Stimulate increments over time for animations. Use it in conjunction with any performant DOM manipulation system (vanilla javascript, jQuery, React, Angular).
Animation is achieved by showing a rapid sucession of frames. Stimulate's frame triggering is controlled through javascript: with window.requestAnimationFrame when it's available in the browser, and a recursive setTimeout method when it's not. Stimulate offers performance optimizations, such as real-time accurate progress reporting regardless of browser-performance-affected framerate conistency, frame-call batching, and progress report syncing over simultaneous Stimulate instances, and initial frame customizability. More depth on those later.
Stimulate does not use CSS3 transitions or @keyframes. CSS3 methods have their place, but they shortcoming like browser rendering complications, awkward javascript API, limited easing capabilities, and inefficient DOM-sniffing progress lookup. CSS3 animations have some advanatages, like easy assignability in css and better framerates in browsers lacking requestAnimationFrame.
You might prefer javascript-frame-based animation over CSS3 methods when interactive performance is critical, like for swiping/throwing elements. For simpler applications, like animating button hover/touch state, you might prefer CSS3 methods.
Here are some basic examples of using Stimulate in various popular contexts. These will animate an element from left to right a total of 95px over one second.
var elFoo = getElementById('foo');
stimulate({
from: 5,
to: 100,
duration: 1000,
frame: function(progress){
elFoo.style.transform = 'translate3d(' + progress.tweened + 'px 0 0)';
}
});
var Component = React.createClass({
getInitialState: function () {
return {
xPosition: 5
};
},
componentDidMount: function() {
stimulate({
from: 5,
to: 100,
duration: 1000,
frame: function(progress){
this.setState({
xPosition: progress.tweened
});
}
});
},
render: function () {
var style = {
transform: 'translate3d(' + this.state.xPosition + 'px 0 0)'
};
return
Hello
;
}
});
var $elFoo = $('#foo');
stimulate({
from: 5,
to: 100,
duration: 1000,
frame: function(progress){
$elFoo.css({
transform: 'translate3d(' + progress.tweened + 'px 0 0)'
});
}
});
For the sake of simplicity, the remaining examples in the documentation will use jQuery.
In the examples above, see the basic structure of the stimulate call
//call to the library
stimulate(
//settings
{
from:5,
to: 100,
duration: 1000,
easing: function(ratioCompleted){
// sine-out easing function
return Math.sin(ratioCompleted * Math.PI/2)
},
frame: function(progress) {
//affect the DOM
$elFoo.css({
transform: 'translate3d(' + progress.tweened + 'px 0 0)'
});
}
}
);
This will increment $elFoo from 5 to 100 over 1 second (1000 milliseconds). One additional setting is included here, easing
. Stimulate does not come with an easing library baked in. You must write your own or include functions from compatible libraries. One such compatible library can be imported with npm install eases --save
. To see an example in this repo, go to ./src/demo/demo.js
.
When you call stimulate(settings);
, requestAnimationFrame/setTimeout-fallback, will update a progress object and call the frame
callback over and over.
Look at the progress
argument in the frame
callback setting...
progress
is an object that is passed into the frame
callback. This is its structure:
{
"ratioCompleted":0.8089999999999999,
"easedRatioCompleted":0.9553299583633394,
"tweened":77.80999999999999,
"easedTweened":90.97969625270055,
"aspects":{
"someChild_Y":{
"ratioCompleted":0.8089999999999999,
"easedRatioCompleted":0.9912251264838419,
"tweened":307.41999999999996,
"easedTweened":376.6655480638599,
"aspects":{
"asdf":{
"ratioCompleted":0.7623452345,
"easedRatioCompleted":0.7623452345,
"tweened":0.7623452345,
"easedTweened":0.7623452345,
"aspects":{}
}
}
}
}
}
This is an incrementation from 0 to 1. It ignores the from
, to
, and easing
properties. With a duration of 1000ms, exactly half way through the animation, progress.ratioCompleted
will be 0.5.
If an easing
function setting was specified, progress.easedRatioCompleted
is the product of applying progress.ratioCompleted
value to that function. If there is no easing setting, it's value is the same as progress.ratioCompleted
.
This is the value between the settings.from
and settings.to
according to this point in time relative to the duration, without easing. So if from: 10
, to: 20
and duration: 1000
, after 300 milliseconds, progress.tweened
is 13. After 500 milliseconds, it's 15. It's a linear progression. If no from
setting is specified, this value is the same as progress.ratioCompleted
.
This is like progress.tweened
, but instead of progressing linearly from from
to to
, it uses the easing
setting to determine its position between from
and to
. If no easing setting exists, its value matches progress.tweened
. This is the the most useful property in the progress
object for typical animation applications. This is how you get bouncy movements.
Stimulate lets you nest instances in an aspects
setting object (more on this later). progress.aspects
lets you access the progress of nested descendants. In the example below, notice how the to level frame
callback accesses the progress of someChild_Y
in order to calculate the position for $foo
.
var $foo = $('.foo'); // make sure you cache your selectors
stimulate({
from:10,
to:20,
duration: 1000,
easing: circOut,
frame: function(progress){
var x = progress.easedTweened;
var y = progress.aspects.someChild_Y.easedTweened;
};
$foo.css({
transform: 'translate3d(' + x + 'px ' + y + 'px 0)'
});
},
aspects: {
someChild_Y: {
from: -142,
to: 345,
duration: 642,
easing: sineOut,
frame: function(progress){
// This CB is here if you need it
// but this instance's progress
// is accessible in its parent progress.aspects
// see below.
},
aspects: {
asdf:{
delay: 13
}
}
}
},
});
As we've seen, the progress object is accessible as an argument of the frame
setting handler. But it's accessible in other ways. There are other callbacks for onComplete
and onStop
, all of which have progress
as their first argument.
Progress is also a property on the object that calling stimulate
returns. Stimulate()
returns an object -- an instance of the StimulateAspect class. More on this later.
Also, you should be aware that the progress
object is never destroyed and recreated for updates. The progress
identity persists -- only its properties get updated. To illustrate this, follow truth
in the example below to see how various progress
references match eachother:
var truth = true;
var mainProgress;
var aspectProgress;
var myStimulation = stimulate({
from: 5,
to: 10,
duration: 1000,
aspects: {
foo:{
from: 12,
to: 423,
duration:243,
frame: function(progress){
truth = truth && progress === this.progress;
aspectProgress = progress;
}
}
},
frame: function(progress){
truth = truth && progress === this.progress;
truth = truth && myStimulation.progress === progress;
truth = truth && progress.aspects.foo === aspectProgress;
mainProgress = progress;
}
});
setTimeout(function(){
truth = truth && mainProgress === myStimulation.progress;
console.log(truth === true); //true
},100);
Calling stimulate({/*settings*/})
creates an instance of a class called StimulationAspect
, and returns it. That returned object can be assigned to a variable and it has methods ready to be called and properties ready to be accessed.
See how this is used in the example below, where StimulationAspect is controlled by a button, that when clicked, stops the animation, reverses it, display the current ratioCompleted in an element, waits a half a second and resumes:
var myStimulation = stimulate({
from: 5,
to: 100,
duration:1000,
easing: spring,
frame: function(){
$foo.css('top',this.progress.easedTweened+'px')
};
});
var reversed = false;
$button.on('click', function(){
myStimulation.stop().updateSettings({
reverse: !!reversed
});;
$meter.text(myStimulation.progress.ratioCompleted);
setTimeout(function(){
myStimulation.resume();
}, 500)
});
Notice that some methods like stop
are chainable. There will be more detail on various StimulationAspect methods later.
StimulationAspect instances can have StimulationAspect child instances. In this example, this section will descript the relationship between parent and child aspects.
var myStimulation = stimulate({
from: 5,
to: 100,
duration: 600,
aspects: {
someChild: {
from: 43,
to: 29,
aspects: {
someGrandChild:{
from: 3,
to: 99999
}
}
},
someOtherChild: {
duration: 300,
from: 12,
to: 77
}
},
frame: function(progress){
console.log(progress.aspects.someChild.aspects.someGrandChild);
}
});
progress
objects of descendantsThis can be done in several ways.
var val = myStimulation.aspects.someChild.aspects.someGrandChild.progress
;
or
var val = myStimulation.progress.aspects.someChild.aspects.someGrandChild.progress
;
or
var val = myStimulation.progressAt('someChild.someGrandChild');
This can be done in a couple of ways.
var val = myStimulation.aspects.someChild.aspects.someGrandChild
or
var val = mystimulation.aspectAt('someChild.someGrandChild');
For a settings like this, if a child does not have it specified, it will assume the value of its parent. Grandchildren will have this relationship with children, and so on. So a parent's setting can potentially impact a great-great-grandchild's assumed setting. Stimulate has a .updateSettings()
method. Calling this on a parent will update any children/grandchildren that are dependant on inheritence. Even if you update settings in the middle of an animation, the inheritance will take effect.
Here are the inheritable settings.
Stimulate has additional settings. A comprehensive list of settings will be described later.
In the example above, myStimulation.progress.ratioCompleted
and myStimulation.aspects.someChild.progress.ratioCompleted
will reach their respective to
values at the same time, but myStimulation.aspects.someOtherChild.progress.ratioCompleted
will reach its to
value 300 milliseconds before that. So, myStimulation.aspects.someChild
inherited duration
setting from its parent myStimulation
.
myStimulation.stop()
will effectively call myStimulation.aspects.someChild.stop()
, which would call myStimulation.aspects.someChild.aspects.someGrandChild.stop()
.
resetAll()
has this behavior as well.
There are two ways to do this. The first is nesting child aspect settings within the parent's setting of the original call. Like this:
stimulate({
duration:100,
aspects: {
someChild: {
duration: 200
}
}
});
The second way to spawn a child is by calling .birthChild
on a StimulationAspect. Like this:
var myStimulation = stimulate({duration: 100});
var someChildOfMyStimulation = myStimulation.birthAspect('someChild',{duration:200}');